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 vide it seems it is working, may be I am doing something wrong. can anyone looked into the code below.
[code]<?php
mysql_connect(‘localhost’,‘root’,’’);
?>
<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"; } } else{ mysql_query("INSERT INTO 'users'.'user_info' ('username','password','email') VALUES('".$username."', '".md5($password)."','".$email."');"); } } ?> [/code]