我是網絡編程的新手。我試圖學習PHP和HTML。我用導航欄創建了一個主頁(index.html)。我把這個href放到一個名爲register_form.php的表單中,它會進入頁面,但是在我鍵入所有信息並單擊註冊按鈕後,它會轉到源頁面。我試圖找到一些答案,搜索,但我無法解決問題。我使用一個程序來發送我的文件和PHP,它是XAMP。我激活了所有的模塊來表示tomcat,因爲我無法使用。問題提交按鈕
Register_form.php
<HEAD>
<link rel="stylesheet" type="text/css" a href="web_style.css"/>
</HEAD>
<div class="caixas">
<form action="register.php" method="POST">
First Name: <input type="text" name="name" /><br/>
Last Name: <input type="text" name="lname" /><br/>
Username: <input type="text" name="uname" /><br/>
Email: </br><input type="text" name="email1" /><br/>
Confirm Email: <input type="text" name="email2" /><br/>
Password: <input type="password" name="pass1" /><br/>
Confirm Password: <input type="password" name="pass2" /><br/>
<div class="regbut">
<input class="reg" type="submit" value="Register" name="submit" />
</div>
</form>
</div>
register.php
<?PHP
require('config.php');
$erro = '<script type="text/javascript">alert("Sorry, your passwords do not match.");</script>';
if(isset($_POST['submit'])){
//Verificacao
$email1=$_POST['email1'];
$email2=$_POST['email2'];
$pass1=$_POST['pass1'];
$pass2=$_POST['pass2'];
if($email1==$email2){
if($pass1==$pass2){
//Continuar
$name=mysql_escape_string($_POST['name']);
$lname=mysql_escape_string($_POST['lname']);
$uname=mysql_escape_string($_POST['uname']);
$email1=mysql_escape_string($_POST['email1']);
$email1=mysql_escape_string($email1);
$email2=mysql_escape_string($email2);
$pass1=mysql_escape_string($pass1);
$pass2=mysql_escape_string($pass2);
mysql_query("INSERT INTO login_data (name, lname, uname, email, pass) VALUES ('".$name."','".$lname."','".$uname."','".$email1."','".$pass1."')");
header("Location: index.html");
}else{
echo $erro;
exit();
}
}else{
echo 'Sorry, your emails do not match. </br>';
}}
?>
如果您需要了解更多信息,請告訴我。在此先感謝
你是什麼意思「時,進入源頁」? –
當我點擊註冊按鈕時,它顯示我寫的代碼(register.php) – Miguel
您確定您正在服務器上運行php嗎? –