【发布时间】:2015-05-01 16:40:13
【问题描述】:
老实说,我不知道出了什么问题。每次我尝试将帐户添加到我的 xml 数据库文件时,它都不会写入文件中。我看不出我的代码有什么问题。
当我点击提交按钮时,会显示此页面的内容
物体移动
此文档可在此处找到
//这是我在下面测试我的代码
嘿,我在 if 语句中 霍格沃茨老板 赃物 hogwartsBoss@gmail.com 哈利 波特 BabyMetal 头部邦亚!! 铁娘子跑到山上 japybunnyhijapygen@yahoo.com Genesis Bejarano
HTML 注册文件
<!--This is the sign up section on the Home Website page -->
<form method="post" action="sign_up.php">
First Name:<input type= "text" name="first"/><br /><br />
Last Name:<input type= "text" name="last"/><br /><br />
Email:<input type= "text" name="email"/><br /><br />
Username:<input type= "text" name="username"/><br /><br />
Password:<input type= "password" name="password"/><br /><br />
<input type= "submit" name="submit" value="Sign up"/>
</form>
PHP 注册文件
$f = $l = $e= $user = $pass = null;
if(isset($_POST['username']) && !empty($_POST['username'])) {
echo "hey im in the if statement";
include 'xmlconnect.php';
$f=vaildName($_POST['first']);
$l=vaildName($_POST['last']);
$e=vaildEmail($_POST['email']);
$user= $_POST['username'];
$pass= $_POST['password'];
$credTag = $xml->addChild('credentials');
//user account info
$userTag = $credTag->addChild('username',$user);
$passTag = $credTag->addChild('password',$pass);
$emailTag = $credTag->addChild('email',$e);
$infoTag = $credTag->addChild('info');
$firstTag = $infoTag->addChild('first',$f);
$lastTag = $infoTag->addChild('last',$l);
file_put_contents('UserAccountDB.xml',$xml->asXML());
echo $xml->asXML();
// echo "updated database";
// printf($xml);
//redirects you to the homepage
session_start();
$_SESSION['userName'] = $user;
//$url = "http://cs3360.cs.utep.edu/gbejarano/WebStore/UserAccountDB.xml";
//$url = "http://cs3360.cs.utep.edu/gbejarano/WebStore/myLibrary.php";
//$url = 'http://localhost/Music_Webstore/myLibrary.php';
header('Location: '.$url);
}
【问题讨论】:
-
请发表您的错误
-
完成@nomistic 希望这会有所帮助
-
您可能需要在文件中指定对象的完整路径,因为找不到它
-
我以为我是用表单的操作部分来做的?
-
请显示您的代码的最低工作量,例如xmlconnect.php 和您的 xml 的有效最小 sn-p。
标签: php html user-input xml