我试图在php中将1个表单的值转换为另一个表单。在form1中有r字段,如姓名,电子邮件等。在提交表单后,它将转到另一个表单,其中名称,电子邮件值从form1显示。但在我的表单名称中,电子邮件不会以form2显示。这是代码。
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/>
答案 0 :(得分:0)
试试这个或更多PHP Header Location with parameter
//after submitting form
header("Location: form2.php?fname=".$fname);
//then
isset($_GET['fname']){
echo $fname;
}
答案 1 :(得分:0)
您正在使用 echo $ _GET ['fname'];但是你是通过表单发送帖子的?