@ginerjm, calm down, he is a beginner, perhaps if everyone was to put what they thought was the appropriate answer, then one may speak to the OP.
If the process was blocked in to processes:
1. Check for a real web form ($_POST['submit'])
2. Sanitize inputs in to a safe variable / array using a whitelist
3. Validation of the data streams, do they contain data, if not flag it.
4. If we pass validation: Create the email body, variables for sending the email
5. send email and capture any send resulting from the process
6. handle any error or success response
That to me sums up the process involved.
Please remember to wrap any code you have in forum tags:-
[CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]
If you can't think outside the box, you will be trapped forever with no escape...
I did not mean to cause offense. I did what I thought you meant.
I got error checking implemented.
There's a lot more wrong with this code, but I'll let you try it first once you get the error checking implemented.
I understood that validation is set to true
What the h.... is 'validationok' meant accomplish for you?
but if a field is empty then validation is false
if it is true an email is sent
and a web page is presented
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
if not then an error page is presented.
I know I am doing something wrong and to you I am not worthy, but I try.
I am sorry I offended you.
Yes - you have the idea to set a var to true or false in order to find out if your inputs are valid. BUT - where did you check the var to see if it was true or not?
if you mean how do I say it is a success or is not, that is where I am confused. I thought I had to declare a var to say it is a success. I think that is where I make mistakes.
if $validationOK is true then it is a success. So I declare $validationOK to be $success ?
I think I will do what you said before and start from nothing.
again, thank you for helping.
You have no idea how to program in any language, do you? The idea of testing a series of things and setting a switch ("a variable with just two values", ie, on/off, no/yes, true/false, etc.) is a perfectly valid structure that one uses to come up with a final result and provide direction as to what to do next is a commond practice. In your case you used a var called validationok and set it to false when you found an error. At the end of your series of tests though you have to do something with that variable like CHECK IT! You are not checking it. Just because you set it to false doesn't mean your program is going to react to it. YOU have to write some code to check if it is true or false and THEN do something according to that answer.
A simple pseudo sample:
(do some tests and set 'varok' to false when any one fails)
(if varok == false)
create an error message saying there is a problem
send the form and the error message back to the client
continue on with your script
In your code you do some tests and set a var to false but then you just go right on sending the email whether or not the var is true or false. Do you get that?
Now I understand what you are saying to me. I will work on this.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread