mysql - Error's With Signup & Login PHP with Hostinger -
so have been building forum friend & has challenged me lot of server side stuff tries designing & receive lot of these error's
disclaimer: know alot of has been posted find hard understand me.
disclaimer: intermediate not expert @ php , have debugged hours on this.
here login.php
<?php //this page let log in include('config.php'); if(isset($_session['username'])) { unset($_session['username'], $_session['userid']); setcookie('username', '', time()-100); setcookie('password', '', time()-100); ?> <!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" /> <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="style" /> <title>login</title> </head> <body> <div class="header"> <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="forum" /></a> </div> <div class="message">you have been logged out.<br /> <a href="<?php echo $url_home; ?>">home</a></div> <?php } else { $ousername = ''; if(isset($_post['username'], $_post['password'])) { if(get_magic_quotes_gpc()) { $ousername = stripslashes($_post['username']); $username = mysql_real_escape_string(stripslashes($_post['username'])); $password = stripslashes($_post['password']); } else { $username = mysql_real_escape_string($_post['username']); $password = $_post['password']; } $req = mysql_query('select password,id users username="'.$username.'"'); $dn = mysql_fetch_array($req); if($dn['password']==sha1($password) , mysql_num_rows($req)>0) { $form = false; $_session['username'] = $_post['username']; $_session['userid'] = $dn['id']; if(isset($_post['memorize']) , $_post['memorize']=='yes') { $one_year = time()+(60*60*24*365); setcookie('username', $_post['username'], $one_year); setcookie('password', sha1($password), $one_year); } ?> <!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" /> <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="style" /> <title>login</title> </head> <body> <div class="header"> <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="forum" /></a> </div> <div class="message">you have been logged.<br /> <a href="<?php echo $url_home; ?>">home page</a></div> <?php } else { $form = true; $message = 'the username or password entered not good.'; } } else { $form = true; } if($form) { ?> <!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" /> <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="style" /> <title>login</title> </head> <body> <div class="header"> <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="forum" /></a> </div> <?php if(isset($message)) { echo '<div class="message">'.$message.'</div>'; } ?> <div class="content"> <?php $nb_new_pm = mysql_fetch_array(mysql_query('select count(*) nb_new_pm pm ((user1="'.$_session['userid'].'" , user1read="no") or (user2="'.$_session['userid'].'" , user2read="no")) , id2="1"')); $nb_new_pm = $nb_new_pm['nb_new_pm']; ?> <div class="box"> <div class="box_left"> <a href="<?php echo $url_home; ?>">forum index</a> > login </div> <div class="box_right"> <a href="list_pm.php">your messages(<?php echo $nb_new_pm; ?>)</a> - <a href="profile.php?id=<?php echo $_session['userid']; ?>"><?php echo htmlentities($_session['username'], ent_quotes, 'utf-8'); ?></a> (<a href="login.php">logout</a>) </div> <div class="clean"></div> </div> <form action="login.php" method="post"> please, type ids log:<br /> <div class="login"> <label for="username">username</label><input type="text" name="username" id="username" value="<?php echo htmlentities($ousername, ent_quotes, 'utf-8'); ?>" /><br /> <label for="password">password</label><input type="password" name="password" id="password" /><br /> <label for="memorize">remember</label><input type="checkbox" name="memorize" id="memorize" value="yes" /><br /> <input type="submit" value="login" /> </div> </form> </div> <?php } } ?> <div class="foot"><a href="http://www.anmolb.esy.es">developers site</a> - developed livinglife_</div> </body> </html>
here error's receive login page.
deprecated: mysql_connect(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/config.php on line 9 warning: mysql_connect(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/config.php on line 9 deprecated: mysql_select_db(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/config.php on line 10 warning: mysql_select_db(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/config.php on line 10 warning: mysql_select_db(): link server not established in /home/u134164949/public_html/forum/config.php on line 10 deprecated: mysql_real_escape_string(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/login.php on line 38 warning: mysql_real_escape_string(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/login.php on line 38 warning: mysql_real_escape_string(): link server not established in /home/u134164949/public_html/forum/login.php on line 38 deprecated: mysql_query(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/login.php on line 41 warning: mysql_query(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/login.php on line 41 warning: mysql_query(): link server not established in /home/u134164949/public_html/forum/login.php on line 41 warning: mysql_fetch_array() expects parameter 1 resource, boolean given in /home/u134164949/public_html/forum/login.php on line 42 deprecated: mysql_query(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/login.php on line 102 warning: mysql_query(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/login.php on line 102 warning: mysql_query(): link server not established in /home/u134164949/public_html/forum/login.php on line 102 warning: mysql_fetch_array() expects parameter 1 resource, boolean given in /home/u134164949/public_html/forum/login.php on line 102
here signup.php code
<?php //this page let users sign include('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"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="style" /> <title>sign up</title> </head> <body> <div class="header"> <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="espace membre" /></a> </div> <?php if(isset($_post['username'], $_post['password'], $_post['passverif'], $_post['email'], $_post['avatar']) , $_post['username']!='') { if(get_magic_quotes_gpc()) { $_post['username'] = stripslashes($_post['username']); $_post['password'] = stripslashes($_post['password']); $_post['passverif'] = stripslashes($_post['passverif']); $_post['email'] = stripslashes($_post['email']); $_post['avatar'] = stripslashes($_post['avatar']); } if($_post['password']==$_post['passverif']) { if(strlen($_post['password'])>=6) { if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_post['email'])) { $username = mysql_real_escape_string($_post['username']); $password = mysql_real_escape_string(sha1($_post['password'])); $email = mysql_real_escape_string($_post['email']); $avatar = mysql_real_escape_string($_post['avatar']); $dn = mysql_num_rows(mysql_query('select id users username="'.$username.'"')); if($dn==0) { $dn2 = mysql_num_rows(mysql_query('select id users')); $id = $dn2+1; if(mysql_query('insert users(id, username, password, email, avatar, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "'.$avatar.'", "'.time().'")')) { $form = false; ?> <div class="message">you have been signed up. can log in.<br /> <a href="login.php">log in</a></div> <?php } else { $form = true; $message = 'an error occurred while signing up.'; } } else { $form = true; $message = 'another user use username.'; } } else { $form = true; $message = 'the email typed not valid.'; } } else { $form = true; $message = 'your password must have minimum of 6 characters.'; } } else { $form = true; $message = 'the passwords entered not identical.'; } } else { $form = true; } if($form) { if(isset($message)) { echo '<div class="message">'.$message.'</div>'; } ?> <div class="content"> <div class="box"> <div class="box_left"> <a href="<?php echo $url_home; ?>">forum index</a> > sign </div> <div class="box_right"> <a href="signup.php">sign up</a> - <a href="login.php">login</a> </div> <div class="clean"></div> </div> <form action="signup.php" method="post"> please fill form sign up:<br /> <div class="center"> <label for="username">username</label><input type="text" name="username" value="<?php if(isset($_post['username'])){echo htmlentities($_post['username'], ent_quotes, 'utf-8');} ?>" /><br /> <label for="password">password<span class="small">(6 characters min.)</span></label><input type="password" name="password" /><br /> <label for="passverif">password<span class="small">(verification)</span></label><input type="password" name="passverif" /><br /> <label for="email">email</label><input type="text" name="email" value="<?php if(isset($_post['email'])){echo htmlentities($_post['email'], ent_quotes, 'utf-8');} ?>" /><br /> <label for="avatar">avatar<span class="small">(optional)</span></label><input type="text" name="avatar" value="<?php if(isset($_post['avatar'])){echo htmlentities($_post['avatar'], ent_quotes, 'utf-8');} ?>" /><br /> <input type="submit" value="sign up" /> </div> </form> </div> <?php } ?> <div class="foot"><a href="http://www.anmolb.esy.es">developers site</a> - developed livinglife_</div> </body> </html>
here error have code
deprecated: mysql_connect(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/config.php on line 9 warning: mysql_connect(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/config.php on line 9 deprecated: mysql_select_db(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/config.php on line 10 warning: mysql_select_db(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/config.php on line 10 warning: mysql_select_db(): link server not established in /home/u134164949/public_html/forum/config.php on line 10 deprecated: mysql_real_escape_string(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/signup.php on line 33 warning: mysql_real_escape_string(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/signup.php on line 33 warning: mysql_real_escape_string(): link server not established in /home/u134164949/public_html/forum/signup.php on line 33 deprecated: mysql_real_escape_string(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/signup.php on line 34 warning: mysql_real_escape_string(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/signup.php on line 34 warning: mysql_real_escape_string(): link server not established in /home/u134164949/public_html/forum/signup.php on line 34 deprecated: mysql_real_escape_string(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/signup.php on line 35 warning: mysql_real_escape_string(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/signup.php on line 35 warning: mysql_real_escape_string(): link server not established in /home/u134164949/public_html/forum/signup.php on line 35 deprecated: mysql_real_escape_string(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/signup.php on line 36 warning: mysql_real_escape_string(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/signup.php on line 36 warning: mysql_real_escape_string(): link server not established in /home/u134164949/public_html/forum/signup.php on line 36 deprecated: mysql_query(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/signup.php on line 37 warning: mysql_query(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/signup.php on line 37 warning: mysql_query(): link server not established in /home/u134164949/public_html/forum/signup.php on line 37 warning: mysql_num_rows() expects parameter 1 resource, boolean given in /home/u134164949/public_html/forum/signup.php on line 37 deprecated: mysql_query(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/signup.php on line 40 warning: mysql_query(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/signup.php on line 40 warning: mysql_query(): link server not established in /home/u134164949/public_html/forum/signup.php on line 40 warning: mysql_num_rows() expects parameter 1 resource, boolean given in /home/u134164949/public_html/forum/signup.php on line 40 deprecated: mysql_query(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/u134164949/public_html/forum/signup.php on line 42 warning: mysql_query(): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2 "no such file or directory") in /home/u134164949/public_html/forum/signup.php on line 42 warning: mysql_query(): link server not established in /home/u134164949/public_html/forum/signup.php on line 42
thank other information, kinda first experience me :)
try putting mysqli_connect
... replace instances of mysql
mysqli
.. you're using procedural approach... , mysqli
offers approach....
mysqli
improve version of mysql
.. don't use mysql
anymore.
Comments
Post a Comment