Results 1 to 2 of 2

Thread: Need Help With My Script

  1. #1
    Join Date
    Aug 2006
    Location
    Seri Kembangan
    Posts
    12
    Rep Power
    0

    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
    }

    ?>

  2. #2
    Join Date
    Jul 2006
    Location
    My
    Posts
    967
    Rep Power
    0
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Matrimonial Script with new feature, shaadi.com clone script
    By sahil101 in forum Website Programming
    Replies: 1
    Last Post: 14-10-2009, 01:23 PM
  2. [WTS]MLM FULL SCRIPT, FULL MLM Script, easy to configure...
    By chardoz in forum Site, Domains and Links Marketplace
    Replies: 1
    Last Post: 10-12-2008, 12:39 AM
  3. How To Convert Shell Script to Batch Script
    By nana86 in forum Website Programming
    Replies: 0
    Last Post: 20-07-2007, 10:04 AM
  4. Help Me With My First Php Script !!!!
    By mya in forum Website Programming
    Replies: 17
    Last Post: 24-01-2004, 06:12 PM
  5. my script can't run..why?
    By therion in forum Website Programming
    Replies: 7
    Last Post: 23-10-2003, 05:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

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