I'm a bit new to answering questions, so bear with me here. And i've read posts, and i've seen that mysql_ is not being used anymore. I know that, so don't tell me not to use it.
Anyhow, I've got this code, and whenever I try to sign up using it, the password isn't hashed in MD5. I've removed the
$mdhash = md5('$name');
because I want your help.
Here is the code:
<?php
session_start();
include('./dbconnect/global.php');
if (isset ($_POST['submit'])) {
$comment = mysql_escape_string (trim ($_POST['username']));
$id = 0;
$date = date("Y-m-d");
if(!empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['email'])){
if ($_POST['username']=="telamon" or $_POST['username']=="brick") {
die("This username is banned");
}
$name = mysql_escape_string (trim ($_POST['password']));
$mdehash = md5($name);
$email = mysql_escape_string (trim ($_POST['email']));
$picture = $_POST['def'];
$tweet = 'NoTweetsTweeted';
$g = mysql_query( "SELECT * FROM admin WHERE username='".$comment."'") or die(mysql_error());
if (mysql_num_rows($g) >= 1) {
$errMsg = "<p style='color:#999999;'>That username is already registerd!</p>";
}else {
if ( preg_match("/^[a-zA-Z0-9]+$/i", $comment) ) {
$sql = mysql_query ("INSERT INTO admin (id,username,password,date,picture,email,twitter) VALUES ('".$id."','".$comment."','".$name."','".$date."','".$picture."','".$email."','".$tweet."')");
header('location: home.php');
}else
$errMsg = "<p style='color:#999999;'>Please fill all fields!</p>";
}
}
}
?>
So, if I could get some help with this, that'd be greatly appreciated! Thanks in advance!