2014-07-21 98 views
-1

当我尝试注册为用户时,为什么我的register.php文件不能执行任何操作?我错过了什么吗?我已经确信我连接到使用config.db为什么我的php代码不能做任何事情?

我的注册页面mysql数据库:

<html> 
<head> 
<title> Register!</title> 
</head> 
<body> 
    <form action="register.php" method="POST"> 

      <h1>Signup!</h1>    

       <p>Create an account:</p> 

       <div> 
        <label for="name">Name:</label> 
        <input type="text" id="name" name="firstname" value="" placeholder="First Name" class="login" /> 
       </div> <!-- /field --> 

       <div> 
        <label for="email">Email Address:</label> 
        <input type="text" id="email" name="email" value="" placeholder="Email" class="login"/> 
       </div> <!-- /field --> 

       <div> 
        <label for="pass">Password:</label> 
        <input type="password" id="password" name="password" value="" placeholder="Password" class="login"/> 
       </div> <!-- /field --> 

       <div> 
        <label for="confirm_password">Confirm Password:</label> 
        <input type="password" id="confirmpassword" name="confirm_password" value="" placeholder="Confirm Password" class="login"/> 
       </div> <!-- /field --> 

       <input type="submit">Register</button>  
     </form> 
    </div> <!-- /content --> 

</div> <!-- /account-container --> 
</body> 

</html> 

我的PHP文件

​​
+5

定义任何东西.. – CharliePrynn

+10

[请不要在新代码中使用'mysql_ *'函数](http://bit.ly/phpmsql)。他们不再被维护[并被正式弃用](https://wiki.php.net/rfc/mysql_deprecation)。看到[红框](http://j.mp/Te9zIL)?学习[*准备的语句*](http://j.mp/T9hLWi),并使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [这篇文章](http://j.mp/QEx8IB)将帮助你决定哪个。如果你选择PDO,[这里是一个很好的教程](http://j.mp/PoWehJ)。 **您也开放给[SQL注入](http://stackoverflow.com/q/60174)** –

+5

请[在学习PDO](http://php.net/pdo)之前,为时已晚,我可以''语法错误附近'吨压力这就够了'' –

回答

10

试着给你的按钮的名称。

<input type="submit" name="submit" value="Register"> 

当您通过表单发布信息时,可以通过名称来调用特定的输入。

在这种情况下,你正在寻找所谓的“提交”一组输入字段:

isset($_POST['submit']) 

但是你没有给任何输入特定的名称,当你点击提交按钮你张贴,如果您给它的名称“提交”,那么你通过'提交'发布,这意味着当你检查'提交'是否发布时,你会得到一个回应。

+1

这看起来似乎是解决方案,但如果您解释了为什么会有所作为,这将有所帮助。 – Quentin

+4

那是无效的HTML。 – CharliePrynn

+0

是的,OP的代码有太多错误...它几乎不值得打捞,应该重新开始。 –

相关问题