我在下面的代码中遇到了问题 [英] I have a problem in below code

查看:88
本文介绍了我在下面的代码中遇到了问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我随时打开我的页面遇到此错误。



未定义索引:移动设备在C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\第4行的CreateAccount.php



我尝试过:



<?php

包括'../dbcon.php';

session_start();

$ mobile = mysqli_real_escape_string($ con, $ _SESSION ['mobile']);

$ result = @ mysqli_query($ con,SELECT memberid FROM members WHERE mobilenumber ='$ mobile');

$ id ='';

while($ row = mysqli_fetch_array($ result)){

$ id = $ row [memberid];

}

?>









< title>创建账户





Anytime I Open My Page I Encounter This Error.

Undefined index: mobile in C:\xampp\htdocs\Church\views\CreateAccount.php on line 4

What I have tried:

<?php
include '../dbcon.php';
session_start();
$mobile = mysqli_real_escape_string($con, $_SESSION['mobile']);
$result =@mysqli_query($con,"SELECT memberid FROM members WHERE mobilenumber='$mobile'");
$id = '';
while ($row = mysqli_fetch_array($result)){
$id = $row["memberid"];
}
?>




<title>Create Account









新用户ID



New User Id








新密码



New Password








确认密码



Confirm Password







<?php

if(isset($ _ POST ['create'])){

$ username = mysqli_real_escape_string($ con,$ _POST ['userid' ]);

$ pwd = mysqli_real_escape_string($ con,$ _POST ['pwd']);

$ role =member;

$ query =INSERT INTO帐户(用户名,成员资格,密码,角色)值('$ username',$ id,'$ pwd','$ role');

if(mysqli_query) ($ con,$ query)){

header(Location:../ Login.php);

} else {

echo'$(\'#alert \')。html(\'< div class =alert alert-danger alert-dismissible>发生错误请再试一次或用户名已经存在< / div> \\ \\'); ';

}

}

?>





函数Validate(){

var pwd = document.getElementById('pwd')。value;

var cpwd = document.getElementById('cpwd' ).value;

if(pwd!= cpwd)

{

var a = $('#alert')。html(' < div class =alert alert-danger alert-dismissible> Password MisMatch< / div>');

$('#pwd')。focus();

setInterval(function(){

$('#alert')。html('');

},3000);

$('#frm')。submit(function(e){

e.preventDefault();

返回false;

})

}

其他

{

$('#frm')。submit(function(ev) ){

ev.submit();

})

}

}




<?php
if(isset($_POST['create'])) {
$username = mysqli_real_escape_string($con, $_POST['userid']);
$pwd = mysqli_real_escape_string($con, $_POST['pwd']);
$role = "member";
$query = "INSERT INTO accounts(username,memberid,password,role) values('$username',$id,'$pwd','$role')";
if (mysqli_query($con, $query)) {
header("Location:../Login.php");
} else {
echo '$(\'#alert\').html(\'<div class="alert alert-danger alert-dismissible">An Error Occured Please Try Again Or Username Already Exists</div>\'); ';
}
}
?>


function Validate() {
var pwd = document.getElementById('pwd').value;
var cpwd = document.getElementById('cpwd').value;
if(pwd != cpwd)
{
var a = $('#alert').html('<div class="alert alert-danger alert-dismissible">Password MisMatch</div>');
$('#pwd').focus();
setInterval(function(){
$('#alert').html('');
}, 3000);
$('#frm').submit(function (e) {
e.preventDefault();
return false;
})
}
else
{
$('#frm').submit(function (ev) {
ev.submit();
})
}
}

推荐答案

mobile = mysqli_real_escape_string(
mobile = mysqli_real_escape_string(


con,


_SESSION ['mobile']);
_SESSION['mobile']);


这篇关于我在下面的代码中遇到了问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆