如何将register.php合并到html [重复]
Posted
技术标签:
【中文标题】如何将register.php合并到html [重复]【英文标题】:how to merge register.php to html [duplicate] 【发布时间】:2013-01-21 06:04:36 【问题描述】:我正在尝试为我的网站创建用户系统。于是我成功地做了一个register.php。
<?php
// dbConfig.php is a file that contains your
// database connection information. This
// tutorial assumes a connection is made from
// this existing file.
include ("dbConfig.php");
//Input vaildation and the dbase code
if ( $_GET["op"] == "reg" )
$bInputFlag = false;
foreach ( $_POST as $field )
if ($field == "")
$bInputFlag = false;
else
$bInputFlag = true;
// If we had problems with the input, exit with error
if ($bInputFlag == false)
die( "Problem with your registration info. "
."Please go back and try again.");
// Fields are clear, add user to database
// Setup query
$q = "INSERT INTO `umass` (`email`,`password`,`school`) "
."VALUES ('".$_POST["email"]."', "
."PASSWORD('".$_POST["password"]."'), "
."'".$_POST["school"]."')";
// Run query
$r = mysql_query($q);
// Make sure query inserted user successfully
if ( !mysql_insert_id() )
die("Error: User not added to database.");
else
// Redirect to thank you page.
Header("Location: register.php?op=thanks");
// end if
//The thank you page
elseif ( $_GET["op"] == "thanks" )
echo "<h2>Thanks for registering!</h2>";
//The web form for input ability
else
echo "<form action=\"?op=reg\" method=\"POST\">\n";
echo "Email Address: <input name=\"email\" MAXLENGTH=\"30\"><br />\n";
echo "Password: <input type=\"password\" name=\"password\" MAXLENGTH=\"16\"><br />\n";
echo "School: <input name=\"school\" MAXLENGTH=\"30\"><br />\n";
echo "<input type=\"submit\">\n";
echo "</form>\n";
// EOF
?>
它有效。当我尝试将我的代码迁移到我的 html 我收到此错误。
die("Error: User not added to database.");
HTML 代码
<div id="register">
register.php code here
</div>
PS 我编辑了我的 htaccess 以运行带有 html 扩展名的 php 脚本。
谢谢
【问题讨论】:
你的情况不清楚... 在你的html文件中加入register.php后请检查dbConfig.php文件的路径 【参考方案1】:将 html 文件更改为 php 并: 试试这个
<div id="register">
<?php include_once('register.php')?>
</div>
【讨论】:
以上是关于如何将register.php合并到html [重复]的主要内容,如果未能解决你的问题,请参考以下文章