Anime Episodes - Debt Consolidation - Debt Consolidation - Credit Reports - Debt Consolidation

PDA

View Full Version : Multiple fields in php form


lizzie87
Mar 9th 2006, 1:35 am
Hello everyone,

I'm busy with this script.. but somehow it isn't working. Hopefully somebody here knows the solution!

I got a form but he doesn't display the filled in options in the e-mail.
He does displays the name, emailaddress, phonenumber and message.. but not the other ones..

The script is a little bit dutch.. (as i'm dutch ;) )
I tried (print_r($_POST)) but that didn't work..

Here's the script:

<?
// is niet 100% !!!
function checkmail($mail)
{
$email_host = explode("@", $mail);
$email_host = $email_host['1'];
$email_resolved = gethostbyname($email_host);

if ($email_resolved != $email_host && eregi("^[0-9a-z]([-_.~]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$mail))
$valid = 1;

return $valid;
}

// geef e-mail adres op van ontvanger
$mail_ontv = "l.bast@ma-web.nl";

// als er niet op submit is gedrukt, of als er wel op is gedrukt maar niet alles ingevoerd is
if (!$_POST['submit'] || $_POST['submit'] && (!$_POST['naam'] || !$_POST['mail'] || !checkmail($_POST['mail']) || !$_POST['msggs']))
{
if ($_POST['submit'] && (!$_POST['naam'] || !$_POST['mail'] || !checkmail($_POST['mail']) || !$_POST['msggs']))
{
echo "U bent uw naam, adres, telefoonnummer of e-mail adres vergeten in te vullen. Ook kan het zijn ";
echo "dat u een verkeerd e-mail adres hebt ingevuld.<p>";
}

// form + tabel
echo "<table border=\"0\" width=\"400px\" cellspacing=\"5\" cellpadding=\"0\">";
echo "<form method=\"POST\" ACTION=\"" . $_SERVER['PHP_SELF'] . "\">";

// space
echo "<tr><td>Bestellijst:<br><br>
</td></tr>";
/////////////////////////////////////////////lampen////////////////////////////////////////////
// space
echo "<tr><td><b>Tafels</b></td>
</tr>";


// naam
echo "<tr>
<td>Foto</td>
<td>Beschrijving</td>
<td>Prijs</td>
<td>Aantal</td></tr>";

echo "<tr>
<td><img src=\"Images/Tafels/01.jpg\" width=\"40px\" height=\"40px\"></td>
<td>tafel 01</td>
<td>&euro; 12,90,-</td>
<td><input type=\"text\" size=\"3\" name=\"tafel1\" value=\"" . $_POST['tafel1'] . "\"></td></tr>";

// space
echo "<tr><td>&nbsp;</td></tr>";

// mail
echo "<tr>
<td><img src=\"Images/Tafels/02.jpg\" width=\"40px\" height=\"40px\"></td>
<td>tafel 02</td>
<td>&euro; 12,90,-</td>
<td><input type=\"text\" size=\"3\" name=\"tafel2\" value=\"" . $_POST['tafel2'] . "\"></td></tr>";

// space
echo "<tr><td>&nbsp;</td></tr>";

// telefoon

echo "<tr>
<td><img src=\"Images/Tafels/03.jpg\" width=\"40px\" height=\"40px\"></td>
<td>tafel 03</td>
<td>&euro; 12,90,-</td>
<td><input type=\"text\" size=\"3\" name=\"tafel3\" value=\"" . $_POST['tafel3'] . "\"></td></tr>";

// space
echo "<tr><td>&nbsp;</td></tr>";

// mail

echo "<tr>
<td><img src=\"Images/Tafels/04.jpg\" width=\"40px\" height=\"40px\"></td>
<td>tafel 04</td>
<td>&euro; 12,90,-</td>
<td><input type=\"text\" size=\"3\" name=\"tafel4\" value=\"" . $_POST['tafel4'] . "\"></td></tr>";

// space
echo "<tr><td>&nbsp;</td></tr>";

// sluit form + tabel
echo "</form>";
echo "</table>";



// form + tabel
echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"0\">";
echo "<form method=\"POST\" ACTION=\"" . $_SERVER['PHP_SELF'] . "\">";

// naam
echo "<tr><td>Naam: </td><td><input type=\"text\" name=\"naam\" value=\"" . $_POST['naam'] . "\"></td></tr>";

// space
echo "<tr><td>&nbsp;</td></tr>";

// mail
echo "<tr><td>E-mail adres: </td><td><input type=\"text\" name=\"mail\" value=\"" . $_POST['mail'] . "\"></td></tr>";

// space
echo "<tr><td>&nbsp;</td></tr>";

// telefoon
echo "<tr><td>Telefoonnummer: </td><td><input type=\"text\" name=\"telefoon\" value=\"" . $_POST['telefoon'] . "\"></td></tr>";

// space
echo "<tr><td>&nbsp;</td></tr>";

// mail
echo "<tr><td>Overige opmerkingen: </td><td><TEXTAREA name=\"msggs\" ROWS=\"6\" COLS=\"35\">" . htmlentities($_POST['msggs']) . "</TEXTAREA></td></tr>";

// space
echo "<tr><td>&nbsp;</td></tr>";

// button
echo "<tr><td>&nbsp;</td></tr>";
echo "<tr><td><input type=\"submit\" name=\"submit\" value=\"Versturen\"></td></tr>";




// sluit form + tabel
echo "</form>";
echo "</table>";
}
// versturen naar
else
{
// set datum
$datum = date("d.m.Y H:i");

// set ip
$ip = $_SERVER['REMOTE_ADDR'];

$inhoud_mail = "===================================================\n";
$inhoud_mail .= "Ingevulde bestellijst\n";
$inhoud_mail .= "===================================================\n\n";

$inhoud_mail .= "Naam: " . $_POST['naam'] . "\n";
$inhoud_mail .= "E-mail adres: " . $_POST['mail'] . "\n";
$inhoud_mail .= "Telefoonnummer: " . $_POST['telefoon'] . "\n";
$inhoud_mail .= "Bericht:\n";
$inhoud_mail .= $_POST['msggs'] . "\n\n";

$inhoud_mail .= "tafel1: " . $_POST['tafel1'] . "\n";
$inhoud_mail .= "tafel2: " . $_POST['tafel2'] . "\n";
$inhoud_mail .= "tafel3: " . $_POST['tafel3'] . "\n";
$inhoud_mail .= "tafel4: " . $_POST['tafel4'] . "\n";

$inhoud_mail .= "Verstuurd op $datum via het ip " . $ip . "\n\n";

$inhoud_mail .= "===================================================\n\n";

// --------------------
// spambot protectie
// ------

$headers = "From: " . $_POST['naam'] . " <" . $_POST['mail'] . ">";

$headers = stripslashes($headers);
$headers = str_replace("\n", "", $headers); // Verwijder \n
$headers = str_replace("\r", "", $headers); // Verwijder \r
$headers = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $headers)); // Slashes van quotes

$_POST['onderwerp'] = str_replace("\n", "", $_POST['onderwerp']); // Verwijder \n
$_POST['onderwerp'] = str_replace("\r", "", $_POST['onderwerp']); // Verwijder \r
$_POST['onderwerp'] = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_POST['onderwerp'])); // Slashes van quotes

mail($mail_ontv, $_POST['onderwerp'], $inhoud_mail, $headers);

echo "Uw bestelling is verstuurd";

echo "<p>Bedankt voor uw bestelling. Wij zullen zo snel mogelijk ";
echo "contact met u opnemen.</p>";

echo "<p>We nemen alles serieus en zullen vertrouwelijk omgaan met de informatie ";
echo "die we binnen krijgen. Uw gegevens zullen nooit aan derden worden verstrekt.</p>";
}
print_r($_POST);
?>


</body>
</html>

digitalpoint
Mar 9th 2006, 1:39 am
What version of PHP are you using? If you don't know, what's the URL for your site, and I'll check for you.

Is there anything specific that's not working? Or just the inability to see the contents of $_POST?

T0PS3O
Mar 9th 2006, 1:42 am
Can you post the parsed HTML output of the form?

Everything looks OK....

lizzie87
Mar 9th 2006, 2:50 am
Thanks for your reply!

This is the link where i uploaded everything:

http://www.lisettebast.nl/Webmenu/tafels.php

It's just that he doesn't displays the filled in fields of:
Tafel 1, 2, 3 and 4

But what's strange is that he does display the filled in fields with name, phonenumer e-mail etc. But he doesn't do this with tafel 1,2,3 and 4...

Really strange..

T0PS3O
Mar 9th 2006, 2:59 am
Somehow it gets split into two forms, according to the FireFox Webdeveloper Toolbar Form Analysis. One has the tafels, the other the rest that does show up.

Found it. You echo </form> twice, splitting it up. See line 89 in your first post. Get rid of the form closing tag. It's too early.

lizzie87
Mar 9th 2006, 3:18 am
Got rid of the closing tag... uploaded the new file.. filled in the form and checked my e-mail.. but still nothing has changed :(

mad4
Mar 9th 2006, 3:39 am
You were closing one form and then opening another on line 96, the browser will assume the first form needs to be closed as soon as it sees another being opened.

Remove the second form opening tag and you should be OK.

T0PS3O
Mar 9th 2006, 3:40 am
Ah yeah, didn't spot the opening of the second. Indeed, there are two, only use one.

lizzie87
Mar 9th 2006, 3:55 am
and that worked! Thanks a lot for helping me! :D