我需要您的帮助。
我只有一个<input>
的名字:
<input type="text" name="name" id="name" class="name_" placeholder="Your Name">
这是我的邮政编码:
<?php
include_once 'includes/db.php';
include_once 'includes/user.php';
include_once'includes/alphaID.php';
$user = new user();
$set_error='';
if(isset($_POST['name']))
{
$name=$_POST['name'];
$rname=$_POST['name'];
$name = alphaID(microtime(true) * 10000);
if (strlen($rname)>0)
{
$set=$user->Create_Name($name,$rname,$uid,$uemail);
if($set)
{
$_SESSION['id']=$set;
}
else
{
$set_error="<span class='seterror'>name is already exists.</span>";
}
}
}
?>
并在此处插入代码:
<?php
class user
{
public function Create_Name($name,$rname,$uid,$uemail)
{
$name= mysql_real_escape_string($name);
$rname= mysql_real_escape_string($name);
$rname= mysql_real_escape_string($rname);
$qu= mysql_query("SELECT id FROM users WHERE rname='$rname'");
if(mysql_num_rows($qu)==0)
{
$id = "{$uid}";
$cekme = mysql_query("SELECT * FROM users WHERE uid = '$id'");
$goster = mysql_fetch_array($cekme);
extract($goster);
$email = "{$email}";
var_dump($name);
var_dump($rname);
$query = mysql_query("INSERT INTO users(name,rname,uid,uemail)VALUES('$name','$rname','$uid','$email')");
return $id=mysql_insert_id() ;
}
else
{
return false;
}
}
}
?>
现在,我正在尝试做。您可以在此处
$name
将此$name
与alphaID.php一起发布。基于microtime()的alphaID()值始终会变化。
喜欢
名称= Lorem临时美元
至
名称= ebO80dHE
现在,我同时想发布
rname
的真实姓名(Lorem impsum dolar)。我的代码发布alphaID
name
但rname
没有发布。名称=
string(8) "ebO80dHE"
rname =
string(0) ""
最佳答案
$name= mysql_real_escape_string($name);
$rname= mysql_real_escape_string($name);
$rname= mysql_real_escape_string($rname);
删除第二行:
$name= mysql_real_escape_string($name);
$rname= mysql_real_escape_string($rname);
另外,尝试在此处打印名称:
if(isset($_POST['name']))
{
$name=$_POST['name'];
$rname=$_POST['name'];
var_dump($rname);
$name = alphaID(microtime(true) * 10000);
if (strlen($rname)>0)
—如果是这样,我看不到您发布的代码中rname
如何为空。尝试在
rname
中的public function Create_Name
开头和之后添加更多的$rname= mysql_real_escape_string
var_dumps-在$rname
变化的任何地方。这应该给出它变为空的确切位置。