vrmetro
asked on
Undefined variable on 2nd page in multi page form
Notice: Undefined variable: error_msg in D:\data\Inetpub\wwwweb_ver ynew\mobil e_form\pla n.php on line 15
15: if ($error_msg){
16: $_SESSION['error_prn']=$er ror_msg;
17: header("Location: page1.php");
18: }
Here is where the error_msg is set:
if ($_POST['email'] === $_POST['vemail']){ //AND check_email($_POST['email' ])){
$_SESSION['email']=$_POST[ 'email'];
} else {
$error_msg .= "E-mail addresses don't match";
}
Any thoughts?
15: if ($error_msg){
16: $_SESSION['error_prn']=$er
17: header("Location: page1.php");
18: }
Here is where the error_msg is set:
if ($_POST['email'] === $_POST['vemail']){ //AND check_email($_POST['email'
$_SESSION['email']=$_POST[
} else {
$error_msg .= "E-mail addresses don't match";
}
Any thoughts?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm sorry, this is the 2nd page, in a multi-page form, and the error msg is set after validation, see below entire code.
<?php
session_start();
if ($_POST['email'] === $_POST['vemail']){ //AND check_email($_POST['email' ])){
$_SESSION['email']=$_POST[ 'email'];
} else {
$error_msg .= "E-mail addresses don't match";
}
$_SESSION ['name'] = $_POST ['name'];
$_SESSION ['mobile_num'] = $_POST ['mobile_num'];
$_SESSION ['password'] = $_POST ['password'];
$_SESSION ['country'] = $_POST ['country'];
//Validation Ended
if ($error_msg){
$_SESSION['error_prn']=$er ror_msg;
header("Location: page1.php");
}
//function check_email($addr){
// return preg_match(".+@.+.[\d\D]+" ,$addr);
//}
//$_SESSION = $_POST;
?>
<?php
session_start();
if ($_POST['email'] === $_POST['vemail']){ //AND check_email($_POST['email'
$_SESSION['email']=$_POST[
} else {
$error_msg .= "E-mail addresses don't match";
}
$_SESSION ['name'] = $_POST ['name'];
$_SESSION ['mobile_num'] = $_POST ['mobile_num'];
$_SESSION ['password'] = $_POST ['password'];
$_SESSION ['country'] = $_POST ['country'];
//Validation Ended
if ($error_msg){
$_SESSION['error_prn']=$er
header("Location: page1.php");
}
//function check_email($addr){
// return preg_match(".+@.+.[\d\D]+"
//}
//$_SESSION = $_POST;
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You might try something like:
$error_msg='';
....
if ($_POST['email'] === $_POST['vemail']){ //AND check_email($_POST['email'
$_SESSION['email']=$_POST[
} else {
$error_msg .= "E-mail addresses don't match";
};
...
15: if ($error_msg <> '' ){
16: $_SESSION['error_prn']=$er
17: header("Location: page1.php");
18: }