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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jahstarr
Forum Newbie
Posts: 3
Joined: Thu May 20, 2010 4:15 pm

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

Post 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);

?>
Last edited by Benjamin on Thu May 20, 2010 4:28 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

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

Post 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"];
jahstarr
Forum Newbie
Posts: 3
Joined: Thu May 20, 2010 4:15 pm

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

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

There are two spaces in there I don't think you want.
jahstarr
Forum Newbie
Posts: 3
Joined: Thu May 20, 2010 4:15 pm

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

Post by jahstarr »

yup that was it thanks bro
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

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

Post 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:
Post Reply