Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8674679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:45:59+00:00 2026-06-12T19:45:59+00:00

To be frank, I am not a coding freak. Basically, This php script validates

  • 0

To be frank, I am not a coding freak. Basically, This php script validates Name & Email field(s) for a ‘Newsletter Subscription’ form. Well, everything seemed to work fine on all browsers. After 2 days, this script stopped working on IE9 & Firefox 14-16. It works fine on Chrome. Could you guys please let me know, what is causing this error?

php script is named signup.php

The ‘echo script alerts’ in the code doesn’t seem to work on FF & IE9. It works absolutely fine on Chrome. This is exactly my problem.

Error on Firefox – Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies.

Action Point on Firefox – All necessary action was taken to counter this error. Nothing worked out.

Error on IE9 – It simply doesn’t respond and stays on the same page.

<?php

ob_start();
session_start();

/*Name Validation.*/
function checkName($name) 
{
$nAccept = array("&", "’", " ",  "-");

if (!ctype_alpha(str_replace ($nAccept, "", $name)))
   {
        return TRUE;
    }
}

/*Email Validation.*/
function checkEmail($email) 
{
   if(mb_eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) 
   {
      return FALSE;
   }
    if (!preg_match("/^[^@]{1,64}@[^@]{1,255}$/i", $email))
    {

        return false;
    }

   list($Username, $Domain) = explode("@",$email);

   if(getmxrr($Domain, $MXHost)) 
   {
      return TRUE;
   }
   else 
   {
      if(fsockopen($Domain, 25, $errno, $errstr, 30)) 
      {
         return TRUE; 
      }
      else 
      {
         return FALSE; 
      }
   }
}


function isInjected($str) {
    $injections = array('(\n+)',
    '(\r+)',
    '(\t+)',
    '(%0A+)',
    '(%0D+)',
    '(%08+)',
    '(%09+)'
    );
    $inject = join('|', $injections);
    $inject = "/$inject/i";
    if(preg_match($inject,$str)) {
        return true;
    }
    else {
        return false;
    }
}

if(checkName($_REQUEST['name']) == TRUE) {
echo "<script>alert('Please enter a Valid Name.');history.back();</script>";
}

elseif (!isset($_POST['email'])) {
echo "<script>alert('Please ensure you have completed all fields before submitting the form. No fields to be left blank.');history.back();</script>";
}

elseif (empty($_POST['name']) || empty($_POST['email'])) {
echo "<script>alert('Please ensure you have completed all fields before submitting the form. No fields to be left blank.Type in only one valid email address.');history.back();</script>";
}

elseif ( isInjected($_POST['email']) ) {
echo "<script>alert('Please ensure you have completed all fields before submitting the form. No fields to be left blank.Type in only one valid email address.');history.back();</script>";
}

elseif(checkEmail($_REQUEST['email']) == FALSE) {
echo "<script>alert('Entered E-Mail is Invalid or The E-Mail does not belong to a valid domain.');history.back();</script>";
}

else{

$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password="root"; // Mysql password 
$db_name="test"; // Database name 
$tbl_name="connect_members_temp"; //table name

mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); 
mysql_select_db("$db_name")or die("cannot select DB");

$confirm_code=md5(uniqid(rand()));

$name=$_POST['name'];
$email=$_POST['email'];

$sql="INSERT INTO $tbl_name(confirm_code, name, email)VALUES('$confirm_code', '$_POST[name]', '$_POST[email]')";
$result=mysql_query($sql);

}
mysql_close();

if($result)
{

// send e-mail to
$to= 'me@localhost';
$thankyou_page = "before_subscription.html";
$email_page = "email_connectivity.html";
$data_page = "email_not_found.html";

$subject="Confirm Your Subscription with XXXXX";


$header="from: XXXXX <donotreply@XXXXX.com>";

$message="Your Confirmation link \r\n";
$message.="Click on this link to confirm your subscription \r\n";
$message.="http://localhost/XXXXX/confirmation.php?passkey=$confirm_code";

// send email
$sentmail = mail($to,$subject,$message,$header);

}

else
{
header( "Location: $data_page" );
}

if($sentmail)
{
header( "Location: $thankyou_page" );
}
else{
header( "Location: $email_page" );
}

?>

Here is the HTML Form

<form action="signup.php" method="post">
        <fieldset>
          <legend>Digital Newsletter</legend>
          <div class="fl_left">
            <input type="text" name="name" value="Enter name here&hellip;" onfocus="this.value=(this.value=='Enter name here&hellip;')? '' : this.value ;" />
            <input type="text" name="email" value="Enter email address&hellip;" onfocus="this.value=(this.value=='Enter email address&hellip;')? '' : this.value ;"/>
          </div>
          <div class="fl_right">
            <input type="submit" name="newsletter_go" id="newsletter_go" value="&raquo;"/>
          </div>
        </fieldset>
      </form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:46:00+00:00Added an answer on June 12, 2026 at 7:46 pm

    You can’t do a redirect and also echo messages on the page. When validation fails, you should echo the message and then exit.

    The reason you’re getting the redirection error is because of the problem GBD mentioned. When validation fails, you never go into the else clause that sets $data_page, but then you do header("Location: $data_page"); anyway.

    Also, after you do that, you then go into the code that sends either $thankyou_page or $email_page. You can only have one Location: header. You need to exit after sending the redirection that you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have UserComments table like this : 1 | Frank | hello world 2
This works in IE8, but not IE9, FF8 or FF9. It seems like something
Given a table like this: [Last Name] [First Name] [DepartmentID] --------------------------------------- Doe John 1
For ease of discussion, consider this basic table (Test) in Access... ID division name
I'm using this code to delete a row in a table, but it's not
On this page: http://www.ntelos.com/wireline/main In both IE7 and FF, but not Chrome or IE6,
I'm not sure why this isn't working. I'm trying to display 2 columns from
This my code if(request.getParameter(btnlogOut) != null) { session.invalidate(); } Its not clear the session....
I found a lyrics API at http://www.lyrdb.com/services/lws-tech.php . It basically returns a set of
I was programming the example code from Frank Luna's book Introduction to 3D Game

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.