PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm new to PHP, only about 3 months in. I'm trying to take a form a user fills out, check the $_POST variables to make sure all is good and if it is then I want to send those variables to a new page to be displayed. If there are Errors then it displays it above the form. Right now I have two outside scripts that check to make sure the email is a valid one and then if all is good another script to mail those variables. On to the code
require('validemail.php');
require('mailsuccess.php');
$Errors = '';
if(isset($_POST['submit']))
{
$Name = Trim(stripslashes($_POST['Name']));
$Tel = Trim(stripslashes($_POST['Phone']));
$Email = Trim(stripslashes($_POST['Email']));
$ConfirmEmail = Trim(stripslashes($_POST['ConfirmEmail']));
$Hdd = Trim(stripslashes($_POST['Hdd']));
$Warranty = Trim(stripslashes($_POST['Warranty']));
$Message = Trim(stripslashes($_POST['Message']));
$Captcha = Trim(stripslashes($_POST['Captcha']));
if (validemail($Email)){
// Make sure the required Fileds are completed and the email addresses match
if (empty($Name)) { $Errors .= "\n Please enter your name."; }
if (empty($Tel)) {$Errors .= "\n Please enter your telephone number."; }
if ($Email !== $ConfirmEmail) {$Errors .= "\n Your email addresses don't match."; }
if ($Captcha !== '4') {$Errors .= "\n The Captcha is incorrect."; }
if (empty($Errors)) {
success($Name, $Tel, $Email, $Hdd, $Warranty, $Message);
/* Here is where I'm trying to figure out how to send the variables to the new page to be displayed */
}
}
else { $Errors .= "\n Please enter a valid email."; }
}
session_start(); // if your sucess() function outputs anything then this line will need to be before success()
$_SESSION = compact('Name', 'Tel', 'Email', 'Hdd', 'Warranty', 'Message'); // this is kinda sloppy, you can also do
//$_SESSION['Name'] = $Name;
//etc...
header('Location: http://example.com/yourpage.php');
exit;
$Name = $_SESSION['Name'];
echo $name;
//or just
echo $_SESSION['Name'];
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.