Thanks for the tips about formating the PHP output.
What's the difference in using \r\n rather than just \n? I've not come across \r before.
"Refresh" is not a defined HTTP header. Whether or not browsers seem to take it to mean "redirect after two seconds", include a link within the document should it fail.
I'm now using this instead. I found it on the section about header on php.net
PHP Code:
// redirect to a different page in the current directory that was requested
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'form.php';
header("Location: http://$host$uri/$extra");
exit;
The isset function only ensures that there is 'name' and 'email' element in the $_REQUEST superglobal, respectively. These are significant tests, but they don't do what you think they do.
I've taken these tests out now. Could this cause significant problems?
To check for actual content, it's best to use regular expressions to match the input against a particular pattern.
I'm using this now:
PHP Code:
//if the email or name fields are blank, redirect to an error message
if ($_REQUEST['email']=="" or $_REQUEST['name'] =="")
{...redirect...}
//otherwise, send the mail
else
{...mail...}
I prefer not to use the $_REQUEST superglobal if source of the data is known. That is, use $_POST for POST data, and $_GET for values in the query string.
So, for example you'd suggest I change this:
PHP Code:
$name = $_REQUEST['name'];
$company = $_REQUEST['company'];
$position = $_REQUEST['position'];
to this:
PHP Code:
$name = $_GET['name'];
$company = $_GET['company'];
$position = $_GET['position'];
?
Can you give an example of when I might us $_POST?
Bookmarks