kann nicht einfügen meiner Daten in die Datenbank phpmyadmin

Hab ich ein problem in meinem code
Ich versuche, ein Registrierungsformular mit php
aber ich kann nicht einfügen meiner Daten in die Datenbank
das ist mein code

registration_form.php

Anmeldeformular

 <body>
 <form method="post" action="register.php">
 <table border="0">

 <tr><td>username: </td><td><input type="text" name="username" /></td></tr>

 <tr><td>Password: </td><td><input type="password" name="password" /></td></tr>

 <tr><td>Confirm Password: </td><td><input type="password" name="confirm_password" /></td></tr>

 <tr><td></td><td><input type="submit" value="submit" /></td></tr>

 </table>
 </form>
 </body>
 </html>

register.php

 $con=mysql_connect("localhost","root","");
 /* Now, we select the database */
 mysql_select_db("login&register");

 /* Now we will store the values submitted by form in variable */
 $username=$_POST['username'];
 $pass=$_POST['password'];
 /* we are now encrypting password while using md5() function */
 $password=md5($pass);
 $confirm_password=$_POST['confirm_password'];

 /* Now we will check if username is already in use or not */
 $queryuser=mysql_query("SELECT * FROM register WHERE username='$username' ");
 $checkuser=mysql_num_rows($queryuser);
 if($checkuser != 0)
 { echo "Sorry, ".$username." is already been taken."; }
 else {

 /* now we will check if password and confirm password matched */
 if($pass != $confirm_password)
 { echo "Password and confirm password fields were not matched"; }
 else {

 /* Now we will write a query to insert user details into database */
 $insert_user=mysql_query("INSERT INTO register (username, password) VALUES ('$username',     '$password')");

 if($insert_user)
 { echo "Registration Succesfull"; }
 else
 { echo "error in registration".mysql_error(); }

 /* closing the if else statements */
 }}

 mysql_close($con);
 ?>

wenn ich auf submit-button, die Fehlermeldung kommt aus

 Object not found!

 The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

 If you think this is a server error, please contact the webmaster.

 Error 404

 localhost
 08/08/12 23:46:37
 Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1

Bitte helfen Sie mir dieses problem zu lösen
Dank

  • Obligatorisch zu erwähnen, dass dein code ist anfällig für sql-injection. Mehr info: php.net/manual/en/security.database.sql-injection.php
  • Auch vielleicht erwähnenswert, dass es gibt viele frameworks für PHP, die nimmt all die Schmerzen aus dem hinzufügen von Authentifizierung in Ihrer app. Warum das Rad neu erfinden?
  • Ich wirklich nicht bekommen, es tatsächlich...
  • Mansfield ist zu sagen, dass die Verwendung der code, den Sie geschrieben haben, bedeutet, dass jemand wird in der Lage sein, zu hacken Ihrer website, löschen Sie alle Benutzer-Informationen, und schlimmer. Google SQL-Injection-Angriff für mehr Informationen. Ich bin darauf hindeutet, dass die Verwendung eines PHP-Frameworks wie Yii (das bietet ein login-system out of the box) werden deutlich zuverlässiger, stabiler und sicherer als alles, was Sie schreiben könnten, selbst.
  • Ich sehe...anw, mein Programm funktioniert schon..danke für die Anregung 🙂
InformationsquelleAutor Budi Czras | 2012-08-08
Schreibe einen Kommentar