Iam Making Register & Login System

Thats My Code

<?php
include ('func.php');
include "Admin/config.php";
?>
<!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" dir="rtl" lang="ar">
<head>
<title>ÇáÊÓÌíá</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<link href="favicon.ico" rel="icon" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="Style.Css" />
</head>
<body>
<?php include "header.html" ?>
<div id="wrap">
<?php
$headers = headers("tabs.html");
$headers = str_replace("{menu}",menu(),$headers);
echo $headers;
?>
<div class="Register_Content"> 
<?php

if($_POST['submit']){
		
		$_POST['username'] = trim($_POST['username']);
		if($_POST['username'] && strlen($_POST['username']) >= 3){
			$query = mysql_query("SELECT `id` FROM `users` WHERE `username`='".$_POST['username']."' LIMIT 1");
			if(mysql_num_rows($query)){
				$error['userexists'] = 'Username exists';
			}
		} else {
			$error['usernameinput'] = 'Please enter a username';
		}
		
		$_POST['email'] = trim($_POST['email']);
		if($_POST['email']){
			 if(!eregi("^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*@[a-zA-Z0-9]+[a-zA-Z0-9_.-])*\.[a-z]{2,4}$", $_POST['email'])){
			  $error['emailerror'] = 'Email Incorrect';
		  } else {
		  	$query = mysql_query("SELECT `id` FROM `users` WHERE `email`='".$_POST['email']."' LIMIT 1");
				if(mysql_num_rows($query)){
					$error['emailexists'] = 'Email exists';
				}
		  }
		} else {
			$error['emailinput'] = 'Please supply an email address';
		}
		
		if($_POST['password1'] && $_POST['password2']){
			if($_POST['password1'] != $_POST['password2']){
				$error['passmismatch'] = 'Passwords don\'t match'; }

}
			
		else {
			$error['passwordinput'] = 'Please enter your password in both fields';
		}
}
if(!$error && $_POST['submit']){
$query = mysql_query(”INSERT INTO users (username, email, password) VALUES (’”.$_POST['username'].”‘, ‘”.$_POST['email'].”‘, ‘”.md5($_POST['password1']).”‘)”);

} else {

?>

<form name="reg" method="post" enctype="application/x-www-form-urlencoded">

<div class="sellform">ÅÓã ÇáÚÖÜÜÜÜÜÜÜÜÜæ <input class="regform" type="text" name="username" size="40" maxlength="100" /><?php echo $error['userexists']; echo $error['usernameinput']; ?></div>

<div class="sellform">ÇáÈÑíÏ ÇáÅáßÜÜÊÑæäí <input class="regform" type="text" name="email" size="40" maxlength="100" /><?php echo $error['emailerror']; echo $error['emailinput']; echo $error['emailexists']; ?></div>

<div class="sellform">ßáãÜÉ ÇáãÜÜÜÜÜÜÜÜÑæÑ <input class="regform" type="password" name="password1" size="40" maxlength="100" /><?php echo $error['passmismatch']; echo $error['passwordinput']; ?></div>

<div class="sellform">ÅÚÇÏÉ ßáãÉ ÇáãÑæÑ <input class="regform" type="password" name="password2" size="40" maxlength="100" /></div>

<br/>

<input class="Register_Button" type="submit" name="submit" value="ÇáÊÓÌíá" />

</form>

<?php
	}
?>

</div>

<div class="linksfooter">
<?php include "links.html"; ?>
</div>

</div>

<?php include "tags.html" ?>

<center>
<?php include "under.html" ?>
</center>

</body>
</html>

The Error From This Code

$query = mysql_query(”INSERT INTO users (username, email, password) VALUES (’”.$_POST['username'].”‘, ‘”.$_POST['email'].”‘, ‘”.md5($_POST['password1']).”‘)”);

But I Dont Know Whats Wrong With It

Coz It Seems To be Ok

I would write it like this just an example

$userName = $_POST["username"];
            $pass = $_POST["password"];
          
            $register = "INSERT INTO mytable(Username,Password) VALUES ('$userName','$pass')";
            
            if(!mysql_query($register)){
                die ('Error could not add value' . mysql_error());
            }

Check maybe with a mysql_error() tag at the end

Use the right single ' and double quotes "

I Dont Know How To Thanks You :)

Thanks So Much Sir

When I Wrote The Code I Think The Encoding Contain Something Wrong

Thanks For Fixing It

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.