I am trying to get the value from 1 form to another in php. In form1 there r fields such as name,email etc. After the submitting the form it goes to another form where name,email value as to display from the form1. But in my form name,email doesnt display in form2. Here is the code.
form1.php
<form method="post" name="XIForm" id="XIForm" action="registration.php">
<p><label>Name</label><br/><input type="text" name="fname" id="fname" value="" style="margin-left:30px;" placeholder="Name"></p>
<p><label>Email</label><br/><input type="text" name="email" id="email" value="" style="margin-left:30px;" placeholder="Email"></p>
<?php
include_once 'db.php';
if(isset($_POST['XISubmit'])) {
$fname= mysql_real_escape_string($_POST['fname']);
$email=$_POST['email'];
$check_email="select * from reg where email='$email'";
$run1=mysql_query($check_email);
if(mysql_num_rows($run1)>0){
echo "<script>alert('email already exits in our database. Please try with Another!')</script>";
exit(0);
}
else{
$query = "INSERT INTO reg(fname,username,password,cpassword,email) VALUES ('$fname','$username','$password', '$cpassword','$email')";
$run11=mysql_query($query);
$to=$_POST['email'];
if($run11){
$_SESSION['sess_user4']=$username;
echo "<script>alert('Registration Successful')</script>";
echo "<script>window.open('attachfile.php', '_self')</script>";
}
}
}
?>
Form2.php
<form method="post" name="XIForm" action="attach.php" enctype="multipart/form-data" onSubmit="return validate();">
<h4 style="color:#6f4617;margin-left:10px;font-size:15px;font-family:Book Antiqua;color:#168eb6"> <b>Welcome <?=$_SESSION['sess_user4']?> </b>
<br/>
<label>Confirm Name</label><br/>
<input type="text" name="name1" id="name1" style="margin-left:30px;" placeholder="Name" value="<?php if(isset($_GET['fname'])) { echo $_GET['fname']; } ?>" />
<br/><br/>