Jump to content

[SOLVED] Empty HTML /php form


nicholaspaul

Recommended Posts

It's a basic form with a script to check required fields (the script is called when SUBMIT is clicked, as opposed to being in the main file itself) but the problem I'm having is that when the page is refreshed because fields are missing, ALL the fields are blank.

 

Is there a simple fix? I can post code and all that, but wondered if this was a common error.

 

Thanks!

 

[i searched and came up emtpy...]

Link to comment
Share on other sites

The existing entry doesn't show up. I even tried an echo to see what value $_POST['name'] had, and it doesnt show up.

 

Here's my original code (minus some content that doesnt affect the code).

 

The page with the form on it:

<?php include('../common/topofthepage.inc'); ?> <!-- logo, menu, date  -->



<div id="content">
<!-- everything goes here -->

</div> <!-- end indent -->


<div id="columnright">
<!-- menu and contents here -->
<p>Payment methods accepted: cheque, Mastercard, Visa, Paypal</p>
<?

if (isset($message))
{ 
echo '<p class="medredi">Please fill out all required fields.<br><br> You message ',$message, '</p>';
}
echo 'Done before - ',$donebefore; //debugging
?>
<form action="../formcheck/10hourscheck.php" method="POST" >
	<input type="hidden" name="subject" value="10 Hours Order ">

	<span class="largered">*</span><span class="smallred"> required fields</span>
        <p class="pl">name<span class="largered">*</span><br>
        <input name="name" size="40"class="pl"type="text">
	<br>company <br>
        <input name="company" size="40"class="pl" >
	<br>address <span class="largered">*</span><br>
        <input name="add1" size="40"class="pl" ><br>
        <input name="add2" size="40"class="pl" >
        <br>city province/state<span class="largered">*</span><br>
        <input name="city" size="25" class="pl">
        
	<input name="province" size="13"class="pl">
	<br>postal code/zip <span class="largered">*</span><br>
        <input name="postal" size="20"class="pl" >
	<br>email <span class="largered">*</span><br>
        <input name="email" size="40"class="pl" >


<br><br>Sign me up for 10 hours of design. I need it for:
<div id="lhs">
<p>
<input type="checkbox" name="ads"> advertising <br>
<input type="checkbox" name="web"> website updates<br>
<input type="checkbox" name="pub"> publications<br>
</p>
</div>

<div id="rhs">
<p>
<input type="checkbox" name="reg"> regular account<br>
<input type="checkbox" name="other"> other<br>
</p>
</div>


<div class="clear"></div>
<p>
<input type="checkbox" name="understand"><span class="largered">* </span> I understand that ...blah blah blah. </p>

<input type="submit" value="Buy" class="orangeb">    
    </form>
</div>
<? include('../common/endofpage.inc'); ?> <!-- bottom of page stuff -->

 

10hoursecheck.php, the code referred to in the above script.

<?php

if (strlen($_POST['name'])>0) //name set?
{
$nameset = TRUE;
}
else
{
$nameset = FALSE;
$message .= ' Name /';
}

if (strlen($_POST['add1'])>0) //address1?
{
$addset = TRUE;
}
else
{
$addset = FALSE;
$message .= ' Address /';
}

if (strlen($_POST['city'])>0) //city?
{
$city = TRUE;
}
else
{
$cityset = FALSE;
$message .= ' City /';
}

if (strlen($_POST['province'])>0) //province?
{
$provinceset = TRUE;
}
else
{
$provinceset = FALSE;
$message .= ' Province /';
}

if (strlen($_POST['email'])>0) //email?
{
$emailset = TRUE;
}
else
{
$emailset = FALSE;
$message .= ' Email Address/';
}

if (strlen($_POST['postal'])>0) //email?
{
$postalset = TRUE;
}
else
{
$postalset = FALSE;
$message .= ' Postal Code /';
}

if (isset($_POST['understand'])) //understand box checked?
{
$checkbox = TRUE;
}
else
{
$checkbox = FALSE;
$message .= ' Check Understand Box /';
}

$name= $_POST['name'];
$company= $_POST['company'];
$add1= $_POST['add1'];
$add2= $_POST['add2'];
$city= $_POST['city'];
$province= $_POST['province'];
$email= $_POST['email'];
$ads= $_POST['advertising'];
$pub= $_POST['pub'];
$other=$_POST['other'];

$summary= "   I may use the time for: ";

if (isset($ads)){
$summary = $summary . " Advertising ";
}
if (isset($web)){
$summary = $summary . " Website ";
}
if (isset($pub)){
$summary = $summary . " Publishing ";
}
if (isset($reg)){
$summary = $summary . " RegularAccount ";
}

$body = 'ORDER: '
.$name
.' just ordered 10 Hours of design. / email:'
.$email
.' / city:'
.$city
.' '
.$province
.' // '
.$summary
.' / Comments:'
.$comments;

if (isset($message))
{
header("Location: ../products/inhouse.php");
}
else
{
mail("info@nburmandesign.com", "*payment required* $subject From $name", $body, 
	" From: $email");
header("Location: ../products/payorder.php");
}
?>

 

 

I hope it's easy to read. I like my code spaced out.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.