gpt4 book ai didi

php - 使用登录页面输入的电子邮件 ID 更新表单

转载 作者:行者123 更新时间:2023-11-29 23:28:52 27 4
gpt4 key购买 nike

我正在尝试使用电子邮件 ID 和密码登录页面。登录页面重定向到申请表,用户在其中输入所有详细信息以及要保存在登录期间输入的电子邮件 ID 中的详细信息。在登录页面中输入的电子邮件 ID 应发布到申请表中,并且为只读。我无法将电子邮件 ID 从登录页面发布到申请表 我该怎么做?

这是一个表格姓名|电子邮件|密码|姓|名|........姓名、电子邮件、密码将使用注册表单输入数据库 这是代码

登录.php

<?php
include('db.php');
if(isset($_POST['action']))
{
if($_POST['action']=="login")
{

$email =mysqli_real_escape_string($connection,$_POST['email']);
$password = mysqli_real_escape_string($connection,$_POST['password']);
$strSQL = mysqli_query($connection,"select * from cvformat where email='".$email."' and password='".md5($password)."'");
$Results = mysqli_fetch_array($strSQL);
if(count($Results)>=1)
{
echo "<script>window.open('form.php','_self')</script>";
}
else
{
echo "<script>alert('Invalid ID or Password!')</script>";
}
}

表单.php

<div id="header" align="center"><img src="images/header.png" alt="" /></div>
<form name="XIForm" id="XIForm" method="POST" action="pdf/pdf1.php">
<table border="0px" cellspacing="0px" cellspacing="10px" align="center" width="700px">



<tr>
<td style="width:200px;"><div class="label"><b >Surname, Name:</b></div></td>
<td><input type="text" name="surname" id="surname" style="width:250px; padding:5px;"/></td>

</tr>
<tr>
<td style="width:200px;"><div class="label"><label><b >Middle Initial:</b></label></div></td>
<td><input type="text" name="mname" id="mname" style="width:250px; padding:5px;"/></td>

</tr>
<tr>
<td style="width:200px;"><div class="label"><label><b >Email ID</b></label></div></td>
<input type="text" name="email" id="email" class="input" size="40" value="<?php if(isset($_GET['email'])) { echo $_GET['email']; } ?>" readonly> <br /> <br />

</tr>

pdf.php

$surname  = "";
$mname = "";
$email = "";
if($_REQUEST["formType"] == "reg") {

$surname = $_REQUEST["surname"];
$mname = $_REQUEST["mname"];
$email = $_REQUEST["email"];
$formType = "reg";
}

$username = "root";
$password = "";
$hostname = "localhost";
$db = "cv";
//connection to the database
$dbhandle = mysqli_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
mysqli_select_db($db,$dbhandle) or die('cannot select db');


if(isset($_POST['update'])){

mysqli_query("UPDATE cvformat SET surname='".$_POST['surname']."', mname='".$_POST['mname']."',dob='".$_POST['dob']."', city='".$_POST['city']."',region='".$_POST['region']."',country='".$_POST['country']."', diocese='".$_POST['diocese']."', nationality='".$_POST['nationality']."', fname='".$_POST['fname']."',mothername='".$_POST['mothername']."', edate='".$_POST['edate']."', city2='".$_POST['city2']."', region2='".$_POST['region2']."',country2='".$_POST['country2']."',datef='".$_POST['datef']."',dateo='".$_POST['dateo']."',city3='".$_POST['city3']."',region3='".$_POST['region2']."' WHERE email='".$_POST['hidden']."'") or die(mysqli_error());


};

代码有什么问题。

最佳答案

您的 Window.open 脚本刷新页面,随着页面刷新,post 值变得不真实。

许多程序员不建议在 PHP 中调用脚本。

如果我是你,我就不会刷新页面。相反

//if user submited the form
if(isset($_POST['action']) {
//fetch user input values
//verify the input values with database
if($loginBool){
//show content after login
} else {
//show error form
}
} else {
//show login form
}

关于php - 使用登录页面输入的电子邮件 ID 更新表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26728883/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com