Jump to content

Form Problem


RaythMistwalker

Recommended Posts

Ok after a break from php i've came back and my mum has asked me to make her a website which involves sending an email to her through form. Unfortunately I cannot test if it is working due to an error somewhere here:

 

$randNumber = $_POST['randnumber'];
echo "Entered: ".$randNumber;
$realNumber = $_POST['number'];
echo "<br>Actual: ".$realNumber;
    $to = "[email protected]";
    $subject = "Cake Order";
    $name = $_POST['name'];
    echo $name;
    $email = $_POST['email'];
    echo $email;

 

The error validation part is:

    if($name == '') {
        $errmsg_arr[] = 'Name Missing';
        $errflag = true;
    }
    if($email == '') {
        $errmsg_arr[] = 'Email Missing';
        $errflag = true;
    }
    if( $randNumber != $realNumber ) {
        $errmsg_arr[] = 'Incorrect Random Number Entered into Box';
        $errflag = true;
    }
if($errflag) {
        $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
}

 

Here is the form:

<form action='order.php' method='POST'>
    <table>
    <tr><td>(*)Full Name</td><td><input type='text' name='name'> </td></tr>
    <tr><td>(*)Email</td><td><input type='text' name='email'></td></tr>
    <tr><td>(*)Phone</td><td><input type='text' name='phone'></td></tr>
    <tr><td>(*)Address (Street)</td><td><input type='text' name='address'></td></tr>
    <tr><td>(*)City</td><td><input type='text' name='city'></td></tr>
    <tr><td>(*)Postal Code</td><td><input type='text' name='postcode'></td></tr>
    <tr><td>(*)Event (What is cake for?)</td><td><input type='text' name='event'></td></tr>
    <tr><td>(*)Deadline Date (When cake is needed)</td><td><input type='text' name='deadline'></td></tr>
    <tr><td>Any Other Information:</td><td><textarea rows="9" name="extrainfo" cols="30"></textarea></td></tr>
    <tr><td>(*)Enter The Random Number below:<br>
<? echo $randNumber; ?></td><td><input type='text' name='randnumber'></td></tr>
<input type='hidden' value='<? echo $randNumber; ?>' name='number'>
    <tr><td></td><td><input type='submit' name='order' value='Order'>  </td></tr>
    </table>

I have excluded the working parts from the PHP code. What I have noticed is the following:

In regard to the random number, the form is not processing the user inputted number (<input type='text' name='randnumber'>) but IS processing the actual one sent by the hidden input.

 

It is not recalling a name or email at all.

 

Any insight?

Link to comment
https://forums.phpfreaks.com/topic/208562-form-problem/
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.