473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

what's wrong with this code? i am getting a blank page when i pass my form data to it

<?php

if(! isset($_POST['username'])) {
header("Location: login.php");
}

mysql_connect(DELETED)
mysql_select_db(DELETED)

$username = $_POST['username'];
$username = mysql_real_escape_string($username);
$result = mysql_query("SELECT userid, pswd FROM users WHERE username = '$username'");

if(mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
$userid = $row['userid'];
$pswd = $row['pswd'];
}

$formpswd = $_POST['password'];
$formpswd = md5($formpswd);

if(mysql_num_rows($result) == 0) {
header("Location: login.php");
} else if($pswd == $formpswd) {
session_unset();
session_destroy();
session_start();
$_SESSION['userid'] = $userid;
header("Location: userhome.php");
}

mysql_close();

?>
--
----------------------------------------------
Posted with NewsLeecher v3.0 Final
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------
Oct 17 '05 #1
3 1614
> <?php

if(! isset($_POST['username'])) {
header("Location: login.php");
}

mysql_connect(DELETED)
mysql_select_db(DELETED)
Put semicolons on the end of the two lines above for starters
$username = $_POST['username'];
$username = mysql_real_escape_string($username);
$result = mysql_query("SELECT userid, pswd FROM users WHERE username = '$username'");
if(mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
$userid = $row['userid'];
$pswd = $row['pswd'];
}

$formpswd = $_POST['password'];
$formpswd = md5($formpswd);

if(mysql_num_rows($result) == 0) {
header("Location: login.php");
} else if($pswd == $formpswd) {
session_unset();
session_destroy();
session_start();
$_SESSION['userid'] = $userid;
header("Location: userhome.php");
}

mysql_close();

?>

Oct 17 '05 #2
an**@the.net wrote:
mysql_connect(DELETED)
mysql_select_db(DELETED)


lines don't end with ;

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Oct 17 '05 #3
nomopofom (an**@the.net) wrote:
<?php

if(! isset($_POST['username'])) {
header("Location: login.php");
}

mysql_connect(DELETED)
mysql_select_db(DELETED)

$username = $_POST['username'];
$username = mysql_real_escape_string($username);
$result = mysql_query("SELECT userid, pswd FROM users WHERE username =
'$username'");

if(mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
$userid = $row['userid'];
$pswd = $row['pswd'];
}

$formpswd = $_POST['password'];
$formpswd = md5($formpswd);

if(mysql_num_rows($result) == 0) {
header("Location: login.php");
} else if($pswd == $formpswd) {
session_unset();
session_destroy();
session_start();
$_SESSION['userid'] = $userid;
header("Location: userhome.php");
}

mysql_close();

?>


If you want the php error reporting, who will tell you what's wrong, instead
of a white page put: error_reporting(E_ALL); at the beginning of your
php code
(if everything works it's better to put it back to: error_reporting(0);
(http://www.php.net/error_reporting)
Oct 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Andre | last post by:
Hi, I need to fetch a value in an Access db, so i use a form to pass the parameter for the SQL statement fromVB client to ASP. After the submit line in VBscript, i expect the value in order to...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
17
by: Paul | last post by:
HI! I get an error with this code. <SCRIPT language="JavaScript"> If (ifp==""){ ifp="default.htm"} //--></SCRIPT> Basicly I want my iframe to have a default page if the user enters in...
4
by: Bill | last post by:
Got a form that pulls data and allows for the user to enter a response in a textbox and I have a button that is supposed to push this reponse text back to the database for that record when clicked....
2
by: Rui Macdonald | last post by:
What is wrong with this code to populate a DropDownList? Can somebody Help me? Tnx RMac ===================================================================================== WebForm.aspx.vb
3
by: Harry2007 | last post by:
How do I get rid of the blank form that attach to the current form when you start to enter data into a continuous form? I want the blank form to only appear after they click on the ADD Record button...
11
pbmods
by: pbmods | last post by:
A somewhat obscure hack has emerged recently that is an offshoot of the now-infamous XSS. It is known as Cross-Site Request Forgery, or XSRF for short. XSRF is a form of temporary identity theft...
9
by: happyse27 | last post by:
Hi All, In perl script(item b below) where we check if html registration form are filled in properly without blank with the necessary fields, how to prompt users that the field are incomplete...
5
by: Shalini Bhalla | last post by:
hi , A strange error is coming , when i run a php file , all the php and java script executes before submit only which actually should execute after clicking on submit button and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.