Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-12-2006, 02:54 PM
Novice Webmaster
 
Join Date: Aug 2006
Location: Seri Kembangan
Posts: 12
Rep Power: 0
marukochan is on a distinguished road
Need Help With My Script

This script is suppose to check the verification code
1. if exist in db & has not used for registration, direct to registration.php
2. if exist in db & has been used, die ('Code has expired')
3. if does not exist, die ('invalid code').

My problem is after I tried to enter a valid code, this error came out
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\project paper\mogec project\ver.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\project paper\mogec project\ver.php on line 42

What is wrong with my header??

The code goes

<?php
// Connects to your Database
mysql_connect("localhost", "root", "admin") or die(mysql_error());
mysql_select_db("project_db") or die(mysql_error());



//if the login form is submitted
if (isset($_POST['submit'])) { // if form has been submitted

// makes sure they filled it in
if(!$_POST['code']) {
die('You did not fill in the code.');
}

// checks it against the database

$check = mysql_query("SELECT * FROM code WHERE code_string = '".$_POST['code']."'")or die(mysql_error());

//Gives error if user doesn't exist
$check2 = mysql_num_rows($check);
if ($check2 == 0) {
die('Invalid code');
}

while($info = mysql_fetch_array( $check ))
{


//gives error if code has been used
if ($info['code_status'] != "") {
die('Verification Code Has Expired');

}

else
{


//then redirect them to the members area
header("Location: members.php");
}
}
}
else
{

// if they are not logged in
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table border="0">
<tr><td colspan=2><h4>Enter verification Code</h4></td></tr>
<tr><td>Code:</td><td>
<input type="text" name="code" maxlength="40">
</td></tr>
<tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Login">
</td></tr>
</table>
</form>
<?php
}

?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-12-2006, 04:52 PM
robot's Avatar
Senior Webmaster
 
Join Date: Jul 2006
Location: My
Posts: 969
Rep Power: 48
robot will become famous soon enough
to use header() to redirect the page, you should not print or display any output BEFORE the header() line. if you print out any output before the line, the same error would appear.
try to check your code without the header() first and see which error was printed and then move the error code below the header() line.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for MLM Php script masrule Website Programming 0 24-01-2007 01:56 PM
script nurulmajdi Website Programming 12 16-02-2004 04:03 PM
Help Me With My First Php Script !!!! mya Website Programming 17 24-01-2004 06:12 PM
my script can't run..why? therion Website Programming 7 23-10-2003 05:14 PM
cgi script Seman Website Programming 6 16-09-2003 05:46 PM



All times are GMT +8. The time now is 05:46 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60