Jump to content

Archived

This topic is now archived and is closed to further replies.

omerta

Form had been processed but it did not redirect the page

Recommended Posts

Hello!

Form had been processed but it did not redirect the page; Happens only in IE browser but runs ok in Mozilla Firefox and Opera.

The script is shown below. This is a card number and serial code validation script for our online voting of Mr. and Ms. Photogenic Search. The system requires every voter to purchase an online voting card with the number and serial code combination as pass key for voting. The pass key combination should only be used once, which means the next time you login with the same card and serial nos., it will return a card expiry message. My problem lies on redirecting the page to "/now.php" after it had processed the form. Our voters had complained that after they register with their name, email, card no. and serial no. and submit the form, they are stuck within the same page (form submit page). When they tried to login again with the same card, they get the card expiry message.

Can anyone help me figure out where my problem lies? Any help would be greatly appreciated. Thanks.

The script:
[code]<?php

ob_start(); //Start output buffering

// Set the page title
$page_title = 'Voters Information Log';

if (isset($_POST['submit'])) { // Handle the form.

setcookie('serial_no', $_POST['serial_no']);

// check for db connection
require_once ('dbcon.php');

$message = NULL; // Create an empty new variable.

// Check for voter information
if (empty($_POST['name'])) {
$nm = FALSE;
$message .= "<p>Please enter your name!</p>";
} else {
$nm = $_POST['name'];
}

if (empty($_POST['email'])) {
$em = FALSE;
$message .= "<p>Please enter your email!</p>";
} else {
$em = $_POST['email'];
}

if (eregi("^[_0-9]{4,6}$", $card_no)) {
$cn = FALSE;
$message .= '<p><font color="red" size="+1"> INVALID card number!</font></p>';
} else {
$cn .= $_POST['card_no'];
}

if (eregi("^[[:alnum:]]{8,10}$", stripslashes(trim($_POST['serial_no'])))) {
$sn = escape_data($_POST['serial_no']);
} else {
$sn = FALSE;
$message .= '<p><font color="red" size="+1"> Bad card and serial number combination!</font></p>';
}
}

// End of validation
if ($nm && $em && $cn && $sn) { // If everythings ok.

//Check if the card and serial no. is genuine
$query = "SELECT id FROM users WHERE password='$sn'";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);

if ($row) {//serial code is genuine

// Check if the serial code is still valid for use
$query = "SELECT id FROM voters_log WHERE serial_no='$sn'";
$result = @mysql_query ($query);

if (mysql_num_rows($result) == 0) { //If none returned, serial code is still valid for use

// Permit the user with his card and serial nos.
$query = "INSERT INTO voters_log(name, email, card_no, serial_no, date_voted)
VALUES ('$nm', '$em', '$cn', '$sn', NOW())";
$result = @mysql_query ($query); //run the query

if ($result) { //if successful

ob_end_clean(); //delete the buffer

// redirect to verification
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/now.php");

exit();

} else {
$message = '<p>Your request is temporarily blocked due to a system error. We apologize for any inconvenience.</p><p>' . mysql_error() . '</p>';
}
} else { // If the card and serial nos. had been used already
$message = '<p><font color="red" size="+1">Sorry! Your ONLINE VOTING CARD had expired.</font></p>';
}
} else { // If the card and serial nos. combination is not genuine
$message = '<p><font color="red" size="+1">The card and serial numbers do not match those on our file.</font></p>';
}

mysql_close();

} // End of the main submit conditional

//Set the page title and include header.
$page_title = 'Mr. and Ms. Photogenic - Image Model Search 2006';
include ('header_v.inc');

// Print the message if there is one.
if (isset($message)) {
echo '<span class="error">' , $message, '</span>';
}

?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
            <!--DWLayoutTable-->
            <tr>
              <td width="219" height="42" valign="top"><p class="style1Copy">Please enter information:</p></td>
              <td width="392" rowspan="2" valign="top"><form action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST">
                    <p>
                      <span class="style1">
                      Your Name<br />
                      <input name="name" type="text" class="style1" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>"/>
                      <span class="style4">                      *                      </span></span><span class="style4">Required for card ownership validation.</span><span class="style1"><br />
                      Your Email <br />
                      <input name="email" type="text" class="style1" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" />
                      </span>                      <span class="style4"> * Required for contact purposes.</span><span class="style1"><br />
                      Card No. <br />
                      <input name="card_no" type="text" class="style1" value="<?php if (isset($_POST['card_no'])) echo $_POST['card_no']; ?>" />
                      </span><span class="style4">*</span><span class="style1"> <br />
                      Serial No. <br />               
                      <input name="serial_no" type="text" class="style1" value="<?php if (isset($_POST['serial_no'])) echo $_POST['serial_no']; ?>"/>
                    <span class="style4">* </span></span></p>
                    <p>
                      <span class="style1">
                      <input type="submit" name="submit" value="Sign In" />
                      </span> </p>
              </form>                <p>&nbsp;</p></td>
        </tr>
            <tr>
              <td height="209" valign="top" class="ins">Please read
                <a href="../how_to_vote.php" class="ins"><br>
                VOTING INSTRUCTIONS</a> <br />
                carefully
                before attempting <br />
                to
              login.</td>
            </tr>
          </table>

<? include ('footer_v.inc');
ob_end_flush(); //delete the buffer
?>
[/code]

Share this post


Link to post
Share on other sites
I'm not sure what would be the cause. It's odd that it works in Firefox/Mozilla and Opera but not IE.  Can you echo the string passed to the header() function and see what it is.  Maybe it's something weird with that string that IE can't handle properly.  I see nothing wrong with the code.

Share this post


Link to post
Share on other sites
Thanks for replying so soon.

Actually, it doesn't happen in every IE browser because it worked on my pc. I sort of figure out maybe some of the voters didn't have their IE browsers set to accept cookies or they did not use the default settings for the browser, therefore, causing the loop and redirection to index page. Our report says, complaints were coming from those who voted using a rented pc (internet cafes). Most I-netCafe turned off this feature to their browsers.

Here it is...

now.php
[code]<?php require_once ('verify2.php'); ?>

<?php

ob_start(); //Start output buffering

// Set the page title
$page_title = 'Voters Information Log';

if (isset($_POST['submit'])) { // Handle the form.

// check for db connection
require_once ('dbcon.php');

$message = NULL; // Create an empty new variable.

if (eregi("^[_0-9]{4,6}$", $card_no)) {
$cn = FALSE;
$message .= '<p><font color="red" size="+1"> INVALID card number!</font></p>';
} else {
$cn .= $_POST['card_no'];
}

if (eregi ("^[[:alnum:]]{8,10}$", stripslashes(trim($_POST['serial_no'])))) {
$sn = escape_data($_POST['serial_no']);
} else {
$sn = FALSE;
$message .= '<p><font color="red" size="+1"> INVALID serial number!</font></p>';
}
}

// End of validation
if ($cn && $sn) { // If everythings ok.

// Check if the serial code is still valid for use
$query = "SELECT id, name FROM voters_log WHERE card_no='$cn' AND serial_no='$sn'";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);

if ($row) { //If none returned, serial code is still valid for use

setcookie ('name', $row[1]);
setcookie ('id', $row[0]);

ob_end_clean(); //delete the buffer

header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/vote_app.php"); //start voting application

exit();

} else {
$message = '<p>The card and serial numbers you entered did not match with our registry.</p><p>' . mysql_error() . '</p>';
}

mysql_close();

} // End of the main submit conditional

//Set the page title and include header.
$page_title = 'Mr. and Ms. Photogenic - Image Model Search 2006';
include ('header_v.inc');

// Print the message if there is one.
if (isset($message)) {
echo '<span class="error">' , $message, '</span>';
}

?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
            <!--DWLayoutTable-->
            <tr>
              <td height="27" colspan="2" valign="top"><p class="style1">Please re-enter card
                and serial numbers
              for verification:</p></td>
            </tr>
            <tr>
              <td width="252" height="239" valign="top" class="ins"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td width="715" valign="top"><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
                    <p>
                      <span class="style1">                      </span><span class="style1">
                      Card No. <br />
                      <input name="card_no" type="text" class="style1" value="<?php if (isset($_POST['card_no'])) echo $_POST['card_no']; ?>" />
                      </span><span class="style4">*</span><span class="style1"> <br />
                      Serial No. <br />               
                      <input name="serial_no" type="text" class="style1" value="<?php if (isset($_POST['serial_no'])) echo $_POST['serial_no']; ?>"/>
                <span class="style4">* </span></span></p>
                    <p>
                      <span class="style1">
                      <input type="submit" name="submit" value="Sign In" />
                      </span> </p>
              </form>                <p>&nbsp;</p></td>
        </tr>
          </table>

<?php include ('footer_v.inc');
ob_end_flush(); //delete the buffer
?>[/code]

verify2.php
[code]<?php

ob_start(); //Start output buffering

//if no cookie is present, redirect the user.
if (!isset($_COOKIE['serial_no'])) {

ob_end_clean(); //delete the buffer
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php");

exit(); //quit script
}
?>[/code]

index.php
[code]<?php
$URL="http://sampleurl.com/login/get_log.php";
header ("Location: $URL");
?>
[/code]

Share this post


Link to post
Share on other sites
Yeah nothing looks wrong about it.  Odds are the whole disabling cookies theory may be correct.  I really can't think of anything else that could be a problem.

Share this post


Link to post
Share on other sites
Hi, I have a similar, but more simple problem.
I have a search form that's supposed to pass two variables, 'srch' being the search string and 'Search' being the page that's supposed to load.

[quote]
<form method="get" action="index.php" style="width:190px">
<input type=text name='srch' maxlength=255 style="width:150px">
<input type=submit name='section' value="Search" style="font-size:10px ">
</form>
[/quote]

in firefox it works fine, the url is "index.php?section=Search&srch=blah"
but my office server only uses ie, and there's the problem.
the url for that is "index.php?srch=blah", and it simply redirects me to the newspage which defaults if 'section' is null.

ive tried to get around this with if statements instead

[quote]
if(isset($_GET['srch'])){
  include('Search.php?srch='.$srch);
} else if(isset($_GET['section'])){
  include($section.'.php');
} else {
  include('news.php');
}
[/quote]

everything flows as it should, except the include('Search.php?srch='.$srch); which doesn't seem to run at all

can someone please help? either by getting around IE or telling me what's wrong w/ that include() statement. thanks

Share this post


Link to post
Share on other sites
If you include a file... you don't need to pass it the variable... you can just access it within the search.php page

Share this post


Link to post
Share on other sites
ah! that was more simple than i thought. i feel really stupid now hehe

thanks a lot

Share this post


Link to post
Share on other sites
Don't worry about it :).  I do dumb things like that all the time :) ... just glad to help

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.