PDA

View Full Version : Help with PHP code fir sending form content


ErektheBug
11-18-2011, 09:31 PM
I went to the tutorial section of Dreamweaver Club to create a simple form on my HTML page for visitors to submit their e-mail address and have it e-mailed to me. The instructions seemed simple enough, but when I test it, I get the following errors:


Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /data/9/2/98/105/2587268/user/2837067/htdocs/sendresults.php on line 8

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /data/9/2/98/105/2587268/user/2837067/htdocs/sendresults.php on line 10

Parse error: syntax error, unexpected T_VARIABLE in /data/9/2/98/105/2587268/user/2837067/htdocs/sendresults.php on line 12

I'm not a coder...I'm a designer. The author is no longer available...can somebody help, please...?

edbr
11-19-2011, 12:25 AM
it looks like a server problem from the path not the form perhaps

ErektheBug
11-19-2011, 02:19 AM
it looks like a server problem from the path not the form perhaps

So, I re-did this, and uploaded it...now when I hit 'submit' it opens the page with the php code instead of going to the "confirmation" page...and I don't get an e-mail with the info....

edbr
11-19-2011, 02:38 AM
post the code form and php

ErektheBug
11-19-2011, 05:25 PM
You can see the form at www.ccbf.us/indexbeta.html, and here's the php code I'm using:


<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Results from e-mail submission form';

// Your email address. This is where the form information will be sent.
$emailadd = 'erek@erekthebug.com';

// Where to redirect after form is processed.
$url = 'http://www.ccbf.us/confirmation.html';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

edbr
11-19-2011, 11:32 PM
when i go to your site and submit I can read the php file. its showing <p>&lt;?php<br /> not <?php and ?&gt;</p> instead of ?>. change this in code view, you can loose the <p> tags .