kayıt php dosyası.

0 Cevap php

Ben bu kaydolmak php işe almak için çalışıyorlar. Ben yakın değilim, sanırım. Ama bir sorun var. Sonuç (Sen Ben kodu okurken bahsediyorum ne bileceksiniz.) Lütfen bana sorun bulabilseydim her zaman ana sayfasına yönlendiren bir düğme.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="jmtoday" class=" no_js">
<head>
<link href='icon.jpg' rel='icon' type='image/jpg'/>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-language" content="en" />
<LINK REL=StyleSheet HREF="Mainstyles.css" TYPE="text/css"></link>
<Title>Sign up to JM Today</title>
</head>
<body>
<?php 
 $dbservertype='mysql';
 $servername='localhost';
 $dbusername='***';
 $dbpassword='***';
 $dbname='jmtdy';
 function connecttodb($servername,$dbname,$dbuser,$dbpassword)
 {
  global $link;
  $link=mysql_connect("$servername","$dbuser","$dbpassword");
  if(!$link){
   die("Could not connect to MySQL");
    }  
  mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
connecttodb($servername,$dbname,$dbusername,$dbpassword);
?>


<?php

 $username=mysql_real_escape_string($_POST['username']);
 $password=mysql_real_escape_string($_POST['password']);
 $password2=mysql_real_escape_string($_POST['password_confirmation']);
 $todo=mysql_real_escape_string($_POST['todo']);
 $email=mysql_real_escape_string($_POST['email']);
 $fname=mysql_real_escape_string($_POST['fname']);
 $lname=mysql_real_escape_string($_POST['lname']);



if(isset($todo) and $todo=="post"){

 $status = "OK";
 $msg="";
 }

if(!isset($username) OR strlen($username) <3){
 $msg=$msg."Username should be equal to or more than 3 characters long<BR/>";
 $status= "NOTOK";
 }     

if(mysql_num_rows(mysql_query("SELECT username FROM users WHERE username = '$username'")or die (mysql_error ()))){
$msg=$msg."Username already exists. Please try another one<BR/>";
$status= "NOTOK";}     


if ( strlen($password) < 3 ){
 $msg=$msg."Password must be more than 3 charactors long<BR/>";
 $status= "NOTOK";
 }     

if ( $password <> $password2 ){
 $msg=$msg."Passwords are not identical.<BR/>";
 $status= "NOTOK";
 }     


if($status="NOTOK"){
 echo "$msg<br/><input type='button' value='Retry' onClick='history.go(-1)'>";
}
 else {
if(mysql_query("insert into users(username,password,email,fname,lname) values('$username','$password','$email','$fname','$lname')")or die (mysql_error ())){
 echo "Welcome, You have successfully signed up";
 }
else { 
echo "Database Problem, please contact Site admin";
}

}
?>
</body>
</html>

0 Cevap