Jump to content

Recommended Posts

it wont echo out

echo " successsfully login!".$_SESSION['login']; or

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR...l1-strict.dtd">
<!--
 
 
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Yakity Yak</title>
<link href='http://fonts.googlea...=Oswald:400,300' rel='stylesheet' type='text/css'>
<link href='http://fonts.googlea...css?family=Abel|Satisfy' rel='stylesheet' type='text/css'>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
 
  <p><!-- end #header --></p>
  <div id="header" class="container">
    <div id="logo">
      <h1><a href="#">Yakity Yak</a></h1>
    </div>
    <div id="menu">
      <ul>
        <li class="current_page_item"><a href="homepage.php">Homepage</a></li>
        <li><a href="trip.php">Destinations</a></li>
        <li><a href="contact.php">contact </a></li>
        <li><a href="login.php">Login</a></li>
<li><a href="#">Leader</a></li>
        <li></li>
        <li></li>
      </ul>
    </div>
  </div>
  <blockquote>
    <blockquote>
      <p> <center><img src="sd.jpg" width="999" height="300"  alt=""/></center>  </p>
    </blockquote>
  </blockquote>
  <div id="page">
    <div class="post">
      <h2 class="title"><a href="#">Welcome to Yakity yak club</a></h2>
<h1>Login</h1>
<form action='' method='post'>
Username: <input type='text' name='username'/></br>
password: <input type='password' name='password'/></br>
<input type='submit' value='Login 'name='login'/>

</form> 
 
</body>
</html>
 
<div class="entry">
 
</div>
    </div>
  </div>

</body>
</html>
 
 
<?php
$connect=mysql_connect("localhost","root","");
$db_selected = mysql_select_db("users", $connect); 
if(isset($_POST['login'])){
	
	$username= $_POST['username'];
	$password= $_POST['password'];
	
	if(!$username || !$password){
	echo "Fields were empty.<a href='registration.php'>Back</a>";

	}else{
	
	$find_multiple=" SELECT username FROM resgistration WHERE username='$username' ";
	$query=mysql_fetch_assoc(mysql_query($find_multiple ))or die (mysql_error());
		
		$query_username=$query['username'];
		$query_password=$query['password'];
		
			if($username="$query_username" && $password="$query_password"){
			
			$_SESSION['login']=$username;
			echo " successsfully login!".$_SESSION['login'];
			
			}else{
			echo "Invalid info";
	
	
	}
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/284369-it-wont-echo-out/
Share on other sites

you only select username so there is no password in the row.

 

This is pretty useless exercise

$find_multiple=" SELECT username FROM resgistration WHERE username='$username' ";

You only need to select the password, you already know the username

Edited by Barand
Link to comment
https://forums.phpfreaks.com/topic/284369-it-wont-echo-out/#findComment-1460574
Share on other sites

i ediited the code

$find_multiple=" SELECT username FROM resgistration WHERE username='$username',  ";
	$find_multiple=" SELECT password FROM resgistration WHERE password='$password',  ";
	$query=mysql_fetch_assoc(mysql_query($find_multiple ))or die (mysql_error());

it came out

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\Users\User\Desktop\lo\htdocs\login1.php on line 82
You have an error in your SQL syntax; checkarrow-10x10.png the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Edited by dean012
Link to comment
https://forums.phpfreaks.com/topic/284369-it-wont-echo-out/#findComment-1460577
Share on other sites


}else{

$find_multiple=" SELECT password FROM resgistration WHERE username='$username' ";
$result = mysql_query($find_multiple ) or die (mysql_error());
$query=mysql_fetch_assoc($result);
if (mysql_num_rows($result)==1) {

if($password==$query['password']){

$_SESSION['login']=$username;
echo " successsfully login!".$_SESSION['login'];

}else{
echo "Invalid info";
}

} else {
echo "Invalid info";
}
}

 

Edited by Barand
Link to comment
https://forums.phpfreaks.com/topic/284369-it-wont-echo-out/#findComment-1460579
Share on other sites

i ediited the code

$find_multiple=" SELECT username FROM resgistration WHERE username='$username',  ";
	$find_multiple=" SELECT password FROM resgistration WHERE password='$password',  ";
	$query=mysql_fetch_assoc(mysql_query($find_multiple ))or die (mysql_error());

it came out

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\Users\User\Desktop\lo\htdocs\login1.php on line 82

You have an error in your SQL syntax; checkarrow-10x10.png the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

This code doesn't make sense.

 

1. You define $find_multiple as one query, and then in the next line, you completely overwrite the first query with a second query.

 

2. As someone mentioned earlier, there's no point in selecting out something you already know. Your first query (that gets overwritten) says "Select the username I already know if the username matches the username I already know." Then your second query says "Select the password I already know if the password matches the password I already know."

 

3. Also, this isn't necessarily an error, but it looks very suspicious: is your table name actually resgistration and not registration?

 

4. The mysql_ extension is deprecated. You should use mysqli or PDO.

 

5. It seems as if you're storing your passwords in plain text instead of encrypting them. You should encrypt them.

Link to comment
https://forums.phpfreaks.com/topic/284369-it-wont-echo-out/#findComment-1460599
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.