• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6608
  • Last Modified:

Safari losing POST information when submitting a form to a PHP page

Community,

I have seen several related questions but none to my point, so I'm asking this:

I created a web form (standard html) that submits to a PHP page. The submitted data is just fine when submitted in Firefox and IE, but in Safari (both Mac and PC) no data is received by the PHP page.

The code of the form is here, below is the PHP code to work with the input.


<script language="JavaScript" type="text/javascript">
function Enable_Submit()
{
	if (document.form1.Bedingungen.checked)
	{
		document.form1.Submit.disabled = false;
	}
	else
	{
		document.form1.Submit.disabled = true;
	}
}
</script>
 
// the form
 
<table width="99%" border="0" align="center" cellpadding="10" cellspacing="0">
    <tr>
      <td width="75%" valign="top"><form action="http://www.kyudo-frankfurt.de/antrag.php" method="POST" enctype="enctype=text/plain" name="form1">
          <p>Name:<br>
            <input name="Name" type="text" id="Name" maxlength="50">
          </p>
          <p>Stra&szlig;e:<br>
            <input name="Strasse" type="text" id="Strasse" maxlength="50">
          </p>
          <p>PLZ/Ort:<br>
            <input name="PLZ" type="text" class="plzinput" id="PLZ" maxlength="5">
            <input name="Ort" type="text" class="ortinput" id="Ort" maxlength="50">
          </p>
          <p>Telefon:<br>
            <input name="Telefon" type="text" id="Telefon" maxlength="30">
          </p>
          <p>E-Mail:<br>
            <input name="Mail" type="text" id="Mail" maxlength="50">
          </p>
          <p>Kommentar:<br>
              <textarea name="Kommentar" cols="52" rows="5" id="Kommentar"></textarea>
		</p>
		<p><input class="checkbox" type="checkbox" name="Bedingungen" value="ja" onClick="JavaScript:Enable_Submit()">
            Ich habe die <a href="PDF/Bedingungen_Einsteigerkurs.pdf" target="_blank">Bedingungen zur Anmeldung</a>, die <a href="PDF/Dojo-Etikette.pdf">Dojo-Etikette</a> und die <a href="PDF/Sicherheitsordnung.pdf">Sicherheitsordnung</a> gelesen und akzeptiert.
		  </p>
 
 
          <p> <input class="button" type="submit" name="Submit" value="Abschicken" disabled>
            <input class="button" name="Reset" type="reset" id="Reset" value="Zur&uuml;cksetzen">
          </p>
        </form></td>
    </tr>
  </table>
 
//what follows is the PHP code to process the form data
 
<?php
if ($_POST['Name'])
{
	$MailTo = 'information@kyudo-frankfurt.de';
	$Subject = '[Kyudo-Frankfurt] Anmeldung zum Einsteigerkurs';
	$AdditionalHeader = 'From: webform@kyudo-frankfurt.de' . "\r\n" .
    			'Reply-To: webform@kyudo-frankfurt.de' . "\r\n" .
				'Return-Path: webform@kyudo-frankfurt.de' . "\r\n";
	$Body = 'Die folgenden Daten wurden im Formular übermittelt:'. "\r\n\r\n";
	$Body .= 'Name: ' . $_POST['Name'] . "\r\n";
	$Body .= 'Straße: ' . $_POST['Strasse'] . "\r\n";
	$Body .= 'PLZ, Ort: ' . $_POST['PLZ'] . ' ' . $_POST['Ort'] . "\r\n";
	$Body .= 'E-Mail: ' . $_POST['Mail'] . "\r\n";
	$Body .= 'Kommentar: ' ."\r\n\r\n" . $_POST['Kommentar'] . "\r\n\r\n";
	$Body .= 'Die Bedingungen wurden zur Kenntnis genommen.';
 
	mail($MailTo, $Subject, $Body, $AdditionalHeader);
	echo "<p>Vielen Dank. Wir haben Ihre Anmeldung erhalten und werden uns schnellstens mit Ihnen in Verbindung setzen.</p>";
}
else
	echo('<meta http-equiv="refresh" content="1, f_formular_ek.html">');
?>

Open in new window

0
nick601
Asked:
nick601
  • 3
  • 2
  • 2
2 Solutions
 
nplibCommented:
is the forming submiting, just no data is going? or is the form doing nothing when the submit button is clicked.


also you should have {} around your else conditions.
else {
   echo('<meta http-equiv="refresh" content="1, f_formular_ek.html">');
}
?>

Open in new window

0
 
nick601Author Commented:
Hi nplib,

the form is submitting but no data going (NB: There is Data Going when using IE and FF). REgarding the brackets, yes - I am used to C++ style without brackets in one-liners :) I'll improve

Nick
0
 
nplibCommented:
PHP sometimes acts weird if you mix and match the styles.
 you had brackets in the beginning of the if statement, but not after the if.


try adding
just to see if any data is going

also can you give me the link to the form, maybe I can see something..
<?php
print_r($_POST);
if ($_POST['Name'])
{
        $MailTo = 'information@kyudo-frankfurt.de';
        $Subject = '[Kyudo-Frankfurt] Anmeldung zum Einsteigerkurs';

Open in new window

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
ddrudikCommented:
You might consider:
<form name="form1" action="<?php echo$_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="post">
0
 
nick601Author Commented:
Found the issue. Ddrudik's hint was helpful, the enctype was incorrect (text/plain) submits a blank array in Safari. However also thanks to nplib for the print_r hint in PHP. Didn't know that trick yet.

Nick
0
 
ddrudikCommented:
Thanks for the question and the points.
0
 
nick601Author Commented:
Final comment from me:

Safari (both MAC and PC) appears to be sensitive to the enctype of a form (IE and FF ignore the setting). Be sure to set the enctype to "multipart/form-data".

Also if you're (like me) from an ASP / VB background looking for an alternative to Request.Form - print_r is what you're after in PHP

Cheers dudes.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now