Being a new one in php I am trying to learn simple login example from the video from "TheProgrammingSchool.com" but this code to insert data in the table named "user_info" in the database "users" is not working. But in his video it seems it is working, may be I am doing something wrong. can anyone looked into the code below.
"user_info" table consists of "user_id","username","password" and "email. Here is the code
Code:<?php mysql_connect('localhost','root',''); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title> USERS LOGIN SYSTEM</title> </head> <body> <?php if(!isset($_POST['submit'])) { ?> <form action="index.php" method="post"> <table border="1"> <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>Password Confirm</td><td><input type="password" name="passwordconf"></td> </tr> <tr> <td>Email</td><td><input type="text" name="email"></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="CreateUser" name="submit"></td> </tr> </table> </form> <?php } else { $username=$_POST['username']; $password = $_POST['password']; $passwordconf = $_POST['passwordconf']; $email = $_POST['email']; $errors = array(); if(!$username) { $errors[1] = "You have not entered your username.";} if(!$password) { $errors[2] = "You have not entered your password.";} if(!$passwordconf) { $errors[3] = "You have not enetered your password confirmation.";} if($password !=$passwordconf) { $errors[4] = "You password and password confirmation mismatched.";} if(!$email) { $errors[5] = "You have not enetered your email."; } if( count($errors)>0) { foreach($errors as $error){ echo "$error<br>"; } } else{ mysql_query("INSERT INTO 'users'.'user_info' ('username','password','email') VALUES('".$username."', '".md5($password)."','".$email."');"); } } ?> </body> </html>


Reply With Quote
Bookmarks