Page 1 of 1

College student S.O.S. need help with some code

Posted: Thu May 20, 2010 4:17 pm
by jahstarr
Here is the code can anyone tell me where im going wrong the code is not perfect but i am concerned with why im not getting any data back from the query.sql injections are the furthest thing from my mind at the present moment this is a project for school

Code: Select all

<?php
include 'databaseconnect2.php';

$firstname = $_GET["firstname"];
$email=$_GET["email"];
$password=$_GET["Password"];
$sql="Select password from customer where Email Like '% ".$email." %';";
$result= mysql_query($sql);
$row = mysql_fetch_row($result);
$password2= $row[0];
echo $password2;

function writeName($email,$password,$password2)
{
if ($password2 == $password)
echo "<h1>Welcome back " .$firstname."</h1>";
else
echo "<h1>Invalid login</h1>";


}

writeName($email,$password,$password2);

?>

Re: College student S.O.S. need help with some code

Posted: Thu May 20, 2010 4:32 pm
by mikosiko
first .... did you check that you are really connecting to the DB?

and what are you doing with this variables?... without see the content of your included file they look out-of-place:

Code: Select all

$firstname = $_GET["firstname"];
$email=$_GET["email"];
$password=$_GET["Password"];

Re: College student S.O.S. need help with some code

Posted: Thu May 20, 2010 5:00 pm
by jahstarr
the included file is used for the connection which is not the issue. The problem stems from the code in this file that i have given you. The variables are being passed values from another page that contains a form which passes the information to this page

Re: College student S.O.S. need help with some code

Posted: Thu May 20, 2010 5:05 pm
by requinix
There are two spaces in there I don't think you want.

Re: College student S.O.S. need help with some code

Posted: Thu May 20, 2010 5:48 pm
by jahstarr
yup that was it thanks bro

Re: College student S.O.S. need help with some code

Posted: Thu May 20, 2010 8:57 pm
by mikosiko
tasairis wrote:There are two spaces in there I don't think you want.
I knew it... I knew it.... after Thursday boring "executive" meeting my brain is always a big " F % % T" :)

good catch tasairis :wink: