Jump to content

Scripting-text error


NickG21

Recommended Posts

All im looking to do is implement the php after the submit button has been clicked but when i initially load the site the error message is already displayed and all of the font is in the error text.  here is the code:

<?php
$message = "";
$CompName = "";
$name = "";
$email = "";
$domain = "";
$text = "basictext";

if ($_POST['process'] == 1) {
$pattern = '/.*@.*\..*/';
        $email  = $_POST['YourEmailAddress'];
        $urlname = urlencode($$_POST['YourName']);

if (preg_match($pattern, $_POST['YourEmailAddress']) > 0) {
            // Here's where you would store
            // the data in a database...
            header(
              "location: thanks.html?&username=$urlname");
        }
        $message    = "Please enter a valid email address.";
        $username  = $_POST['name'];
        $text = "errortext";
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<style>
    .basictext {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 14px; color:#000066;
    }
    .errortext {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 14px; color:#C00000; font-weight: bold;
    }
</style>
<body>
  <form method="post" action="cancel.php" onSubmit="return checkCheckBox(this)">
 
<? if ($message != "") {
        print '<span class="errortext">'.
            $message."<span><br>\n";
    }
    ?>
<!-- form content -->
<table class="qForm">
<tr>
<td colspan="2" class="header">Contact Information</td>
</tr>
<tr>
<td class="left"><a>Company Name:</a></td>

<td><input type=text name="CompanyName" size="28" class="basictext" value="<?print $CompName;?>"><br>
</tr>
<tr>
<td class="left"><a>Your Name :</a></td>
<td><input type=text name="YourName" size="28" class="basictext" value="<?print $name; ?>"><br></td>
</tr>
<tr>
<td class="left"><a>Your Email Address:</a></td>

<td><input type=text name="YourEmailAddress" size="28" class=<?print $text; ?>"></td>
</tr>
<tr>
<td class="left"><a>Your List Name or Domain Name:</a></td>
<td><input type=text name="ListDomainName" size="28" value="<? print $domain; ?>"><br></td>
</tr>
</table>
<table class="qForm">

<tr>
<td class="header">Customer Verification Information</td>
</tr>
<tr>
<td ><p class="specialnote"><strong>To verify the authenticity of
your request</strong>, please supply your username and password or the
last 6 digits of the credit card we have on file.  If you do not have
this information please choose "resend the owners manual" and we will
resend this information to the account owner.</p></td>
</tr>
<tr>

<td style="padding: 0 0 0 20px; font-weight: bold; color:
#96855E;">Option 1: Username and Password </td>
</tr>
</table>
<table class="qForm">
<tr>
<td class="left">Username:</td>
<td><input name="Username" class="<? print $text; ?>"><br></td>
</tr>

<tr>
<td class="left">Password:</td>
<td><input name="Password" class="<? print $text; ?>"><br></td>
</tr>
</table>
<table class="qForm">
<tr>
<td style="padding: 0 0 0.5em 20px; font-weight: bold; color: #96855E;">

Option 2: Last 6 Digits of Credit Card Number 
  <input name="Credit Card Number" maxlength="6" size="6">
</td>
</tr>
<tr>

<td><input type="submit" name="Submit" value="Submit"></td>
<td><input type="hidden" name="process" value="1"></td>
</tr>
</table>
</form>
</body>
</html>

could someone please help out?
thank you
Link to comment
https://forums.phpfreaks.com/topic/30800-scripting-text-error/
Share on other sites

in your form, put an hidden field called "formsubmit" and set it's value to 1

<input type="hidden" name="formsubmit" value="1">

then use this code instead of the one you're using

[code]
<?php
if($formsubmit==1)
{
$message = "";
$CompName = "";
$name = "";
$email = "";
$domain = "";
$text = "basictext";

if ($_POST['process'] == 1) {
      $pattern = '/.*@.*\..*/';
        $email  = $_POST['YourEmailAddress'];
        $urlname = urlencode($$_POST['YourName']);

if (preg_match($pattern, $_POST['YourEmailAddress']) > 0) {
            // Here's where you would store
            // the data in a database...
            header(
              "location: thanks.html?&username=$urlname");
        }
        $message    = "Please enter a valid email address.";
        $username  = $_POST['name'];
        $text = "errortext";
    }
}
?>
[/code]

Link to comment
https://forums.phpfreaks.com/topic/30800-scripting-text-error/#findComment-142005
Share on other sites

then set $formsubmit to =0 after the PHP code is executed, like this:

[code]
<?php
if($formsubmit==1)
{
$message = "";
$CompName = "";
$name = "";
$email = "";
$domain = "";
$text = "basictext";

if ($_POST['process'] == 1) {
      $pattern = '/.*@.*\..*/';
        $email  = $_POST['YourEmailAddress'];
        $urlname = urlencode($$_POST['YourName']);

if (preg_match($pattern, $_POST['YourEmailAddress']) > 0) {
            // Here's where you would store
            // the data in a database...
            header(
              "location: thanks.html?&username=$urlname");
        }
        $message    = "Please enter a valid email address.";
        $username  = $_POST['name'];
        $text = "errortext";
    }
}
$formsubmit=0;
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/30800-scripting-text-error/#findComment-142025
Share on other sites

When i implement that code initially the site loads alright, with a lot of issues in the layout, but without the error codes already present.  Is there any certain reason that the tables don't display correctly when i first open the site?  Sorry for the trouble
Link to comment
https://forums.phpfreaks.com/topic/30800-scripting-text-error/#findComment-142052
Share on other sites

Archived

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

×
×
  • Create New...

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.