PDA

View Full Version : Send form results PHP script problem


vinnyvangogh
04-06-2011, 12:44 AM
Hi,

I am using a "sendresults" php script - which I am sure came from DW Club a long time ago.

I have created a Purchase order form and although teh textarea's are in side by side table cells.. the results are recieved thus:-
QTY01:- 1000
Item01:- XXXXXXXXX

I need to results to show like this..
QTY01:- 1000 Item01:- XXXXXXXXX
so teh sales assistants can understand it.

I know - the results over and under are clear as a bell to me and you - but
because its a purchase order... I have to make it idiot proof!

this seems to be teh relevant script.
// --------------------------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.'">';
?>

Can it be changed to put results side by side? and if so HOW!!


TIA

Art

edbr
04-06-2011, 02:08 AM
the form is kinda generic , post the form you use, with all field names and i look at a mail script

vinnyvangogh
04-06-2011, 02:20 AM
<form action="http://www.xxxxxxxxxxxxxxxxx.com/sendresults.php" method="post">
<td colspan="2" align="right">Name</td>
<td colspan="2"><font color="#400000">
<input type="text" name="name" size=40 />
</font></td>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Position</td>
<td colspan="2"><font color="#400000">
<input type="text" name="position" size=40 />
</font></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Company</td>
<td colspan="2"><span class="style93">
<input type="text" name="company" size=40 />
</span></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Telephone</td>
<td colspan="2"><span class="style93">
<INPUT TPYE="text" name="telephone" size=40 />
</span></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">E-Mail</td>
<td colspan="2"><font color="#400000">
<input type="text" name="email" size=40 />
</font></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Purchase Order Number </td>
<td colspan="2"><font color="#400000">
<input type="text" name="Order Number" size=40 />
</font></td>
</tr>
<tr>
<td colspan="4" align="right" bgcolor="#999999">&nbsp;</td>
</tr>
<tr>
<td width="204" align="right" bgcolor="#FFFF99">Quantity 01</td>
<td width="81" align="right" bgcolor="#FFFF99"><input type="text" name="QTY01" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 01 <input type="text" name="Item 01" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 02</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY02" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 02 <input type="text" name="Item 02" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 03</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY0" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 03 <input type="text" name="Item 03" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 04</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY04" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 04 <input type="text" name="Item 04" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 05</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY05" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 05 <input type="text" name="Item 05" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 06</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY06" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 06 <input type="text" name="Item 06" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 07</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY07" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 07 <input type="text" name="Item 07" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 08</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY08" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 08 <input type="text" name="Item 08" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 09</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY09" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 09 <input type="text" name="Item 09" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 10</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY10" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 10
<input type="text" name="Item 10" size=40 />
</font></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="4" align="center">Your Order will be delivered to your Invoice address</td>
</tr>
<tr>
<td colspan="2" align="right" bgcolor="#FFFF66">Delivery Instructions</td>
<td bgcolor="#FFFF66"><span class="style93">
<textarea name="Delivery Address" rows=5 col=70>
</textarea>
&nbsp; </span></td>
<td bgcolor="#FFFF66">&nbsp;</td>
</tr>

<tr>
<td colspan="2" bgcolor="#66CC66"></td>
<td width="68" bgcolor="#66CC66"><input type="submit" value="Submit" name="submit" /></td>
<td width="319" bgcolor="#66CC66"><input type="reset" name="reset" /></td>
</tr>
<tr>
<td colspan="4" bgcolor="#CCCCCC">Questions?&nbsp; Problems?&nbsp;&nbsp; &nbsp;Product Advice?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; Contact Our&nbsp; Sales Team&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;sales@xxxxxxxxx.com</td>
</tr>
</form>

edbr
04-06-2011, 02:48 AM
ok dont have time to test it now but try this. you will need to add quantity and item numbers to suit 2-10 i have left comments. it will chek email is added and validate email. if in error i will correct later



<?php





/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$name = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$telephone = $_POST['telephone'];
$order = $_POST['Order Number'];
$delivery = $_POST['Delivery Address '];

//add for each quty and item
$qyt01 = $_POST['QTY01'];
$item1 = $_POST['Item 01'];




$from = "From:$email \r\n";
$recipient= "info@zzzzzzzzzzzzzzz.com";

//add $qyt02 - $item2 \n
$message = "order number $order \n
$name position $position \n
e mail address $email \n
telephone $telephone \n


$qyt01 - $item1 \n
text $info\n

Delivery Address $delivery \n
";



/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {

echo "<h4>charachters not allowed in this field</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";

}



elseif ($email == "") {
echo "<h4>You must enter an e mail address</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */

elseif (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}


?>

vinnyvangogh
04-06-2011, 03:57 AM
Thanks.. will get back ASAP

vinnyvangogh
04-06-2011, 04:40 AM
the form is kinda generic , post the form you use, with all field names and i look at a mail script

Hi,

Thanks again,

In use after "submit" I get "Invalid email address".

I used a valid email address and used to replace:-
$from = "From:$email \r\n";
$recipient= "info@myemailisok.com (info@myemailisok.com)";

Hope I am not infringing too much on your time..

Art

edbr
04-06-2011, 04:48 AM
but your form has an email post which is being validated .


remove the validation

/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */ if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) { echo "<h4>Invalid email address</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) { echo "<h4>charachters not allowed in this field</h4>"; echo "<a href='javascript:history.back(1);'>Back to e mail form</a>"; } elseif ($email == "") { echo "<h4>You must enter an e mail address</h4>"; echo "<a href='javascript:history.back(1);'>Back to e mail form</a>"; }

vinnyvangogh
04-06-2011, 05:07 AM
The script now looks like this:-
<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$name = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$telephone = $_POST['telephone'];
$order = $_POST['Order Number'];
$delivery = $_POST['Delivery Address '];
//add for each quty and item
$qyt01 = $_POST['QTY01'];
$item1 = $_POST['Item 01'];

$from = "From:$email \r\n";
$recipient= "xxxxxxxx@.com (xxxxxxxx@.com)";
//add $qyt02 - $item2 \n
$message = "order number $order \n
$name position $position \n
e mail address $email \n
telephone $telephone \n

$qyt01 - $item1 \n
text $info\n
Delivery Address $delivery \n
";

/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}

?>

And return this error:-
Parse error: syntax error, unexpected T_ELSEIF in /homepages/45/d91687222/htdocs/xxxxxxxxx.com/poform1.php on line 73

edbr
04-06-2011, 05:21 AM
duh sorry replace elseif
(mail($recipient,$email,$message, $from)) {

with if (mail($recipient,$email,$message, $from)) {

i really shoudnt have rushed this

vinnyvangogh
04-06-2011, 05:42 AM
duh sorry replace elseif
(mail($recipient,$email,$message, $from)) {

with if (mail($recipient,$email,$message, $from)) {

i really shoudnt have rushed this


Sorry... tisme again.

The results are sent to email - but the input info is not returned.

(Missing) Name + input
order number ( missing an dthis is the last entry before PO Number)

position manager

e mail address xxxxx@hotmail.com (wlmailhtml:{17B7D7A1-ED6C-4688-9B97-611B03DBCB12}mid://00000035/!x-usc:mailto:xxxxx@hotmail.com)

telephone 45345 4353453



( QTY Missing) 1000 - (Item No and input missing)

text <- dont know where this came from its not input from me!)


Delivery Address ( missing input)


I have to go out now ( 2.40pm here in NSW aussie)

Thanks for all your time on this - I cannot expect more of your time.

Art

edbr
04-06-2011, 05:51 AM
ok i tested it now i really should have done it before i just ammended an old script
<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$name = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$telephone = $_POST['telephone'];
$order = $_POST['Order Number'];
$delivery = $_POST['Delivery Address '];

//add for each quty and item
$qyt01 = $_POST['QTY01'];
$item1 = $_POST['Item 1'];




$from = "From:$email \r\n";
$recipient= "user@gmail.com";

//add $qyt02 - $item2 \n
$message = "order number $order \n
$name position $position \n
e mail address $email \n
telephone $telephone \n


quantity $qyt01 item $item1 \n


Delivery Address $delivery \n
";



/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {

echo "<h4>charachters not allowed in this field</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";

}



elseif ($email == "") {
echo "<h4>You must enter an e mail address</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */

elseif (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}


?>

?>

vinnyvangogh
04-06-2011, 06:27 AM
Sorry... tisme again.

The results are sent to email - but the input info is not returned.

(Missing) Name + input
order number ( missing an dthis is the last entry before PO Number)

position manager

e mail address xxxxx@hotmail.com (wlmailhtml:{17B7D7A1-ED6C-4688-9B97-611B03DBCB12}mid://00000035/!x-usc:mailto:xxxxx@hotmail.com)

telephone 45345 4353453



( QTY Missing) 1000 - (Item No and input missing)

text <- dont know where this came from its not input from me!)


Delivery Address ( missing input)


I have to go out now ( 2.40pm here in NSW aussie)

Thanks for all your time on this - I cannot expect more of your time.

Art


Hi,

Just checked before going out.

Thanks a million - I'll play with it when I get back and post the results ( of you work) to keep you informed.

Art

vinnyvangogh
04-06-2011, 01:53 PM
Hi,

Just checked before going out.

Thanks a million - I'll play with it when I get back and post the results ( of you work) to keep you informed.

Art


Hi,

'Fraid I am not getting anywhere with the script.

I amended it as to how I thought you indicated -but PHP scripting is greek to me.

Using as sent and changing email to mine... I get the Invalid email error. If I remove the validation section - the script does not send a result form.

I appreciate you have paid work to deal with, so please dont feel obligated to spend more time - I think it must me being a bit thick.

This is how I have mangled it:-
<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$name = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$telephone = $_POST['telephone'];
$order = $_POST['Order Number'];
$delivery = $_POST['Delivery Address '];
//add for each qty and item
$qty01 = $_POST['QTY01'];
$item1 = $_POST['Item 1'];

$from = "From:$email \r\n";
$recipient= "user@hotmail.com";
//add $qyt02 - $item2 \n << this bit confused me - it required per item line
$qty02 = $_POST['QTY02'];
$item01 = $_POST['Item 02'];

$from = "From:$email \r\n";
$recipient= "user@hotmail.com";

$message =
"order number $order \n
name $name \n
position $position \n
email address $email \n
telephone $telephone \n

quantity $qty01 item $item1 \n
quantity $qty02 item $item02 \n
Delivery Address $delivery \n
";

/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {
echo "<h4>charachters not allowed in this field</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";
}

elseif ($email == "") {
echo "<h4>You must enter an e mail address</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}


?>

edbr
04-07-2011, 02:03 AM
ok maybe this will explain and make simpler

the values are passed form your form as a post array, meaning $_POST[''] ie $_POST['QTY01'] from the form field named 'QTY01 and so on

i used a shortend $ by remaming , it is not needed just my way of doing it so try this
<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$name = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$telephone = $_POST['telephone'];
$order = $_POST['Order Number'];
$delivery = $_POST['Delivery Address '];





$from = "From:$email \r\n";
$recipient= "user@gmail.com";

//add $qyt02 - $item2 \n
$message = "order number $order \n
$name position $position \n
e mail address $email \n
telephone $telephone \n


quantity $_POST['QTY01'] item $_POST['Item 1'] \n
quantity $_POST['QTY02'] item $_POST['Item 2'] \n
quantity $_POST['QTY03'] item $_POST['Item 3'] \n


Delivery Address $delivery \n
";



/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {

echo "<h4>charachters not allowed in this field</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";

}



elseif ($email == "") {
echo "<h4>You must enter an e mail address</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */

elseif (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}

?>

?>

add lines
quantity $_POST['QTY04'] item $_POST['Item 4'] \n to match your form field names .

vinnyvangogh
04-07-2011, 04:23 AM
ok maybe this will explain and make simpler

the values are passed form your form as a post array, meaning $_POST[''] ie $_POST['QTY01'] from the form field named 'QTY01 and so on

i used a shortend $ by remaming , it is not needed just my way of doing it so try this
<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$name = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$telephone = $_POST['telephone'];
$order = $_POST['Order Number'];
$delivery = $_POST['Delivery Address '];





$from = "From:$email \r\n";
$recipient= "user@gmail.com";

//add $qyt02 - $item2 \n
$message = "order number $order \n
$name position $position \n
e mail address $email \n
telephone $telephone \n


quantity $_POST['QTY01'] item $_POST['Item 1'] \n
quantity $_POST['QTY02'] item $_POST['Item 2'] \n
quantity $_POST['QTY03'] item $_POST['Item 3'] \n


Delivery Address $delivery \n
";



/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {

echo "<h4>charachters not allowed in this field</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";

}



elseif ($email == "") {
echo "<h4>You must enter an e mail address</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */

elseif (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}

?>

?>

add lines
quantity $_POST['QTY04'] item $_POST['Item 4'] \n to match your form field names .


Hi, Thanks again...

At the risk of really p***ing you off... I just tried the script and got this..

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /homepages/45/xxxxxxx/htdocs/xxxxxxxxxxx.com/poform.php on line 62



line 62 is this:- quantity $_POST['QTY01'] item $_POST['Item 1'] \n

should this :- //add $qyt02 - $item2 \n read //add $qty02 - $item2 \n ( Qty spelt qyt)


What can I be doing wrong if it works in your test.. and does not for me??


Is it a server thing??

edbr
04-07-2011, 04:36 AM
no im p#####ing myself off not you. im just not paying enough attention , ill come back to you

edbr
04-07-2011, 05:27 AM
back with red face :)

first the form i renamed to take out blanks in field names so please replace the form

<form action="sendresults.php" method="post">
<td colspan="2" align="right">Name</td>
<td colspan="2"><font color="#400000">
<input type="text" name="name" size=40 />
</font></td>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Position</td>
<td colspan="2"><font color="#400000">
<input type="text" name="position" size=40 />
</font></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Company</td>
<td colspan="2"><span class="style93">
<input type="text" name="company" size=40 />
</span></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Telephone</td>
<td colspan="2"><span class="style93">
<INPUT TPYE="text" name="telephone" size=40 />
</span></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">E-Mail</td>
<td colspan="2"><font color="#400000">
<input type="text" name="email" size=40 />
</font></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Purchase Order Number </td>
<td colspan="2"><font color="#400000">
<input type="text" name="Order_Number" size=40 />
</font></td>
</tr>
<tr>
<td colspan="4" align="right" bgcolor="#999999">&nbsp;</td>
</tr>
<tr>
<td width="204" align="right" bgcolor="#FFFF99">Quantity 01</td>
<td width="81" align="right" bgcolor="#FFFF99"><input type="text" name="QTY01" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 01 <input type="text" name="Item01" size=40 id="Item01" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 02</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY02" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 02 <input type="text" name="Item02" size=40 id="Item02" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 03</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY03" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 03 <input type="text" name="Item03" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 04</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY04" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 04 <input type="text" name="Item04" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 05</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY05" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 05 <input type="text" name="Item05" size=40 id="Item05" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 06</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY06" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 06 <input type="text" name="Item06" size=40 id="Item06" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 07</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY07" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 07 <input type="text" name="Item07" size=40 id="Item07" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 08</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY08" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 08 <input type="text" name="Item08" size=40 id="Item08" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 09</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY09" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 09 <input type="text" name="Item09" size=40 id="Item09" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 10</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY10" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 10
<input type="text" name="Item10" size=40 id="Item10" />
</font></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="4" align="center">Your Order will be delivered to your Invoice address</td>
</tr>
<tr>
<td colspan="2" align="right" bgcolor="#FFFF66">Delivery Instructions</td>
<td bgcolor="#FFFF66"><span class="style93">
<textarea name="Delivery Address" rows=5 col=70>
</textarea>
&nbsp; </span></td>
<td bgcolor="#FFFF66">&nbsp;</td>
</tr>

<tr>
<td colspan="2" bgcolor="#66CC66"></td>
<td width="68" bgcolor="#66CC66"><input type="submit" value="Submit" name="submit" /></td>
<td width="319" bgcolor="#66CC66"><input type="reset" name="reset" /></td>
</tr>
<tr>
<td colspan="4" bgcolor="#CCCCCC">Questions?&nbsp; Problems?&nbsp;&nbsp; &nbsp;Product Advice?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; Contact Our&nbsp; Sales Team&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;sales@xxxxxxxxx.com</td>
</tr>
</form>


the php script

<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$name = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$telephone = $_POST['telephone'];
$order = $_POST['Order_Number'];
$delivery = $_POST['Delivery Address '];

//add for each quty and item
$qyt01 = $_POST['QTY01'];
$item1 = $_POST['Item01'];

$qyt02 = $_POST['QTY02'];
$item2 = $_POST['Item02'];

$qyt03 = $_POST['QTY03'];
$item3 = $_POST['Item03'];

$qyt04 = $_POST['QTY04'];
$item4 = $_POST['Item04'];

$qyt05 = $_POST['QTY05'];
$item5 = $_POST['Item05'];

$qyt06 = $_POST['QTY06'];
$item6= $_POST['Item06'];

$qyt07= $_POST['QTY07'];
$item7 = $_POST['Item07'];

$qyt08 = $_POST['QTY08'];
$item8= $_POST['Item08'];

$qyt09 = $_POST['QTY09'];
$item9= $_POST['Item09'];

$qyt10 = $_POST['QTY10'];
$item10= $_POST['Item10'];

$from = "From:$email \r\n";
$recipient= "you@gmail.com";

//add $qyt02 - $item2 \n
$message = "order number $order \n
$name position $position \n
e mail address $email \n
telephone $telephone \n


quantity $qyt01 item $item1 \n
quantity $qyt02 item $item2 \n
quantity $qyt03 item $item3 \n
quantity $qyt04 item $item4 \n
quantity $qyt05 item $item5 \n
quantity $qyt06 item $item6 \n
quantity $qyt07 item $item7 \n
quantity $qyt08 item $item8 \n
quantity $qyt09 item $item9 \n
quantity $qyt10 item $item10 \n

Delivery Address $delivery \n
";



/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {

echo "<h4>characters not allowed in this field</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";

}



elseif ($email == "") {
echo "<h4>You must enter an e mail address</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */

elseif (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}


?>

the result
order number 22222222222222222222

dddddddddd position idiot

e mail address you@gmail.com

telephone 44444444444444444



quantity 1 item 1

quantity 2 item 2


quantity 3 item 3

quantity 4 item 4
- Hide quoted text -

quantity 5 item 5

quantity 6 item 6

quantity 7 item 7

quantity 8 item 8

quantity 9 item 9

quantity 10 item 10


Delivery Address

vinnyvangogh
04-07-2011, 07:32 AM
back with red face :)

first the form i renamed to take out blanks in field names so please replace the form

<form action="sendresults.php" method="post">
<td colspan="2" align="right">Name</td>
<td colspan="2"><font color="#400000">
<input type="text" name="name" size=40 />
</font></td>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Position</td>
<td colspan="2"><font color="#400000">
<input type="text" name="position" size=40 />
</font></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Company</td>
<td colspan="2"><span class="style93">
<input type="text" name="company" size=40 />
</span></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Telephone</td>
<td colspan="2"><span class="style93">
<INPUT TPYE="text" name="telephone" size=40 />
</span></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">E-Mail</td>
<td colspan="2"><font color="#400000">
<input type="text" name="email" size=40 />
</font></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="right">Purchase Order Number </td>
<td colspan="2"><font color="#400000">
<input type="text" name="Order_Number" size=40 />
</font></td>
</tr>
<tr>
<td colspan="4" align="right" bgcolor="#999999">&nbsp;</td>
</tr>
<tr>
<td width="204" align="right" bgcolor="#FFFF99">Quantity 01</td>
<td width="81" align="right" bgcolor="#FFFF99"><input type="text" name="QTY01" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 01 <input type="text" name="Item01" size=40 id="Item01" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 02</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY02" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 02 <input type="text" name="Item02" size=40 id="Item02" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 03</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY03" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 03 <input type="text" name="Item03" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 04</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY04" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 04 <input type="text" name="Item04" size=40 />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 05</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY05" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 05 <input type="text" name="Item05" size=40 id="Item05" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 06</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY06" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 06 <input type="text" name="Item06" size=40 id="Item06" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 07</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY07" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 07 <input type="text" name="Item07" size=40 id="Item07" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 08</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY08" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 08 <input type="text" name="Item08" size=40 id="Item08" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 09</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY09" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 09 <input type="text" name="Item09" size=40 id="Item09" />
</font></td>
</tr>
<tr>
<td align="right" bgcolor="#FFFF99">Quantity 10</td>
<td align="right" bgcolor="#FFFF99"><input type="text" name="QTY10" size=12 /></td>
<td colspan="2" bgcolor="#FFFF99"><font color="#400000">
Item 10
<input type="text" name="Item10" size=40 id="Item10" />
</font></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="4" align="center">Your Order will be delivered to your Invoice address</td>
</tr>
<tr>
<td colspan="2" align="right" bgcolor="#FFFF66">Delivery Instructions</td>
<td bgcolor="#FFFF66"><span class="style93">
<textarea name="Delivery Address" rows=5 col=70>
</textarea>
&nbsp; </span></td>
<td bgcolor="#FFFF66">&nbsp;</td>
</tr>

<tr>
<td colspan="2" bgcolor="#66CC66"></td>
<td width="68" bgcolor="#66CC66"><input type="submit" value="Submit" name="submit" /></td>
<td width="319" bgcolor="#66CC66"><input type="reset" name="reset" /></td>
</tr>
<tr>
<td colspan="4" bgcolor="#CCCCCC">Questions?&nbsp; Problems?&nbsp;&nbsp; &nbsp;Product Advice?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; Contact Our&nbsp; Sales Team&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;sales@xxxxxxxxx.com</td>
</tr>
</form>


the php script

<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$name = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$telephone = $_POST['telephone'];
$order = $_POST['Order_Number'];
$delivery = $_POST['Delivery Address '];

//add for each quty and item
$qyt01 = $_POST['QTY01'];
$item1 = $_POST['Item01'];

$qyt02 = $_POST['QTY02'];
$item2 = $_POST['Item02'];

$qyt03 = $_POST['QTY03'];
$item3 = $_POST['Item03'];

$qyt04 = $_POST['QTY04'];
$item4 = $_POST['Item04'];

$qyt05 = $_POST['QTY05'];
$item5 = $_POST['Item05'];

$qyt06 = $_POST['QTY06'];
$item6= $_POST['Item06'];

$qyt07= $_POST['QTY07'];
$item7 = $_POST['Item07'];

$qyt08 = $_POST['QTY08'];
$item8= $_POST['Item08'];

$qyt09 = $_POST['QTY09'];
$item9= $_POST['Item09'];

$qyt10 = $_POST['QTY10'];
$item10= $_POST['Item10'];

$from = "From:$email \r\n";
$recipient= "you@gmail.com";

//add $qyt02 - $item2 \n
$message = "order number $order \n
$name position $position \n
e mail address $email \n
telephone $telephone \n


quantity $qyt01 item $item1 \n
quantity $qyt02 item $item2 \n
quantity $qyt03 item $item3 \n
quantity $qyt04 item $item4 \n
quantity $qyt05 item $item5 \n
quantity $qyt06 item $item6 \n
quantity $qyt07 item $item7 \n
quantity $qyt08 item $item8 \n
quantity $qyt09 item $item9 \n
quantity $qyt10 item $item10 \n

Delivery Address $delivery \n
";



/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {

echo "<h4>characters not allowed in this field</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";

}



elseif ($email == "") {
echo "<h4>You must enter an e mail address</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */

elseif (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}


?>

the result



Thanks for all you help...

(ouch ) before I let you settle down by the sea.... I noticed in your test reults.. the "Delivery address" was no return..
I have tried it online and try as I may to see the logic and flow of the script and shuffle things around - I cannot get a result.

I have returned to the script as sent - I REALLY hate asking this but.....without that box working ...

edbr
04-07-2011, 10:29 AM
change
$delivery = $_POST['Delivery_Address'];

change th form field to suit Delivery_Address, dont use space. i sent you the wrong ammendment , im a wreck today

vinnyvangogh
04-07-2011, 11:29 PM
change
$delivery = $_POST['Delivery_Address'];

change th form field to suit Delivery_Address, dont use space. i sent you the wrong ammendment , im a wreck today


Hi,

You desverve promotion to PRESIDENT!

I cannot thank you enough for the time and effort you have put it to help me with this.

Your fix appeared not to work - till I gathered what was happening,

I have re- jigged a few things and now the reults are sent in the way I was asked to supply.

I, will include the final code for you to check if you want - in a separate post.


To conclude this can I ask a couple of questions. ????

After sending the script throws up a " Thank you" message after sending results. Is there a way I can either have the script open a "confirmation page or add a clickable link.
The end "thank you" page leaves no links to the avaerage office worker to get back to their start position or browser page.

If there is anything i can help with .. I would be happy top recipricate your help.. but you have me beat in web stuff. !

Many thanks

Art

vinnyvangogh
04-07-2011, 11:31 PM
The final working code:-


<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$name = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$telephone = $_POST['telephone'];
$order = $_POST['order_number'];
$delivery = $_POST['delivery_address '];
//add for each quty and item
$qyt01 = $_POST['QTY01'];
$item1 = $_POST['Item01'];
$qyt02 = $_POST['QTY02'];
$item2 = $_POST['Item02'];
$qyt03 = $_POST['QTY03'];
$item3 = $_POST['Item03'];
$qyt04 = $_POST['QTY04'];
$item4 = $_POST['Item04'];
$qyt05 = $_POST['QTY05'];
$item5 = $_POST['Item05'];
$qyt06 = $_POST['QTY06'];
$item6= $_POST['Item06'];
$qyt07= $_POST['QTY07'];
$item7 = $_POST['Item07'];
$qyt08 = $_POST['QTY08'];
$item8= $_POST['Item08'];
$qyt09 = $_POST['QTY09'];
$item9= $_POST['Item09'];
$qyt10 = $_POST['QTY10'];
$item10= $_POST['Item10'];
$from = "From:$email \r\n";
$recipient= "xxxxx@ hotmail.com";
//add $qyt02 - $item2 \n
$message = "
name $name \n
company $company \n
position $position \n
email $email \n
telephone $telephone \n
order $order_number \n
quantity $qyt01 item $item1 \n
quantity $qyt02 item $item2 \n
quantity $qyt03 item $item3 \n
quantity $qyt04 item $item4 \n
quantity $qyt05 item $item5 \n
quantity $qyt06 item $item6 \n
quantity $qyt07 item $item7 \n
quantity $qyt08 item $item8 \n
quantity $qyt09 item $item9 \n
quantity $qyt10 item $item10 \n

delivery $delivery_address \n";



/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='java_script:history.back(1);'>Back</a>";
}
elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {
echo "<h4>characters not allowed in this field</h4>";
echo "<a href='java_script:history.back(1);'>Back to e mail form</a>";
}

elseif ($email == "") {
echo "<h4>You must enter an e mail address</h4>";
echo "<a href='java_script:history.back(1);'>Back to e mail form</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}

?>

edbr
04-08-2011, 02:43 AM
you can either add the code bloch to a normal page or add
header("Location: http://www.example.com/page.html");
exit;
to the end of the script, this will redirect to the page you specify

vinnyvangogh
04-08-2011, 06:15 AM
you can either add the code bloch to a normal page or add
header("Location: http://www.example.com/page.html");
exit;

to the end of the script, this will redirect to the page you specify


Thanks yet again.

If I ever get to Bali - the nights drinks are on me.

Art

PS you can have the weekend off to relax now :)

edbr
04-11-2011, 04:58 AM
not a problem, im smarting at my mistakes in this post actually , as i have just finishing an online art shop let me know if you have any distributors interested in good quality whole sale paintings. :)

vinnyvangogh
04-11-2011, 07:39 AM
not a problem, im smarting at my mistakes in this post actually , as i have just finishing an online art shop let me know if you have any distributors interested in good quality whole sale paintings. :)


OOOppppsss

Guess who is an "amateur" painter -
and who runs a website for a UK top pro Artist!

I'd like to see the art shop - if you PM me.

I am also an ex freelance photographer - sound s grand but I never got rich and give it up to start a real business!
But I have a couple of websites selling prints and posters online using PayPal
coz as you gathered my "coding" skills are zero and PP is quite easy to set up - but needs millions of buttons!

I have sorted the forms out now. made it into a 4 page micro site to plonked in a utiility site to avoid upsetting Google yet again.

I did not make your task easy.. most questions come form those who know a lot but need a nudge - not the illiage idiot with zero knowledge!

10 days on a 4 page micro-site - and about 10 different versions and backup folders!

Thanks again

Art

edbr
04-11-2011, 07:47 AM
ive hit a brick wall sorting our good shipping rares for the time being. so ive just got the basic layout for now only a couple of apaintings actually and the shop closed but have a look by all means its interior-atmospheres.com. i cant pm its disabled on this forum for the time being

vinnyvangogh
01-03-2014, 11:41 PM
This script was OK until a few days ago. My hosts are 1&1 UK and they have changed there server PHP to (options) 5.4 - 5.5 or PHPdev

I had assumed that the change would still allow older PHP version to continue... but it does not! How do I find how to change things to make it work.

vinnyvangogh
01-04-2014, 02:10 AM
This script was OK until a few days ago. My hosts are 1&1 UK and they have changed there server PHP to (options) 5.4 - 5.5 or PHPdev

I had assumed that the change would still allow older PHP version to continue... but it does not! How do I find how to change things to make it work.

I think some of my post went missing! It seems a bit abrupt!! I did send a message using what I thought was a PM.

edbr
01-06-2014, 02:35 AM
gave a suggestion in your other post, if not successful it would be better too see the script as its not clear what the problem could be. but i suspect its a server security issue

vinnyvangogh
01-06-2014, 11:01 PM
Hi,

The script is at the top of this thread, its what you generously created some time ago.
Its been great since it went live on the server, but now they have ceased using the PHP version - on use it reports back "Invalid eMail address". The email is OK, so it means in my not very knowledgable opinion, that the email commands in the script are no longer supported by the PHP 5.4 - 5.5 or dev version now in use by 1&1 UK.

I have searched various PHP forums and tutorials and tried - PHP Storm - which I was told would analyse the script and debit it and suggest a new command... no it didn't and my brain is not capable of PHP!

This is the current - was - in use version,

<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$name = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$telephone = $_POST['telephone'];
$order = $_POST['order_number'];
$delivery = $_POST['delivery'];

//add for each quty and item
$qyt01 = $_POST['QTY01'];
$item1 = $_POST['Item01'];

$qyt02 = $_POST['QTY02'];
$item2 = $_POST['Item02'];

$qyt03 = $_POST['QTY03'];
$item3 = $_POST['Item03'];

$qyt04 = $_POST['QTY04'];
$item4 = $_POST['Item04'];

$qyt05 = $_POST['QTY05'];
$item5 = $_POST['Item05'];

$qyt06 = $_POST['QTY06'];
$item6= $_POST['Item06'];

$qyt07= $_POST['QTY07'];
$item7 = $_POST['Item07'];

$qyt08 = $_POST['QTY08'];
$item8= $_POST['Item08'];

$qyt09 = $_POST['QTY09'];
$item9= $_POST['Item09'];

$qyt10 = $_POST['QTY10'];
$item10= $_POST['Item10'];

$from = "From:$email \r\n";
$recipient= "xxxxxxx@yahoo.com";

//add $qyt02 - $item2 \n
$message = "
name $name \n
company $company \n
position $position \n
email $email \n
telephone $telephone \n
order $order_number \n


quantity $qyt01 item $item1 \n
quantity $qyt02 item $item2 \n
quantity $qyt03 item $item3 \n
quantity $qyt04 item $item4 \n
quantity $qyt05 item $item5 \n
quantity $qyt06 item $item6 \n
quantity $qyt07 item $item7 \n
quantity $qyt08 item $item8 \n
quantity $qyt09 item $item9 \n
quantity $qyt10 item $item10 \n


delivery $delivery \n"
;


/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='java_script:history.back(1);'>Back</a>";
}
elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {

echo "<h4>characters not allowed in this field</h4>";
echo "<a href='java_script:history.back(1);'>Back to e mail form</a>";

}

elseif ($email == "") {
echo "<h4>You must enter an e mail address</h4>";
echo "<a href='java_script:history.back(1);'>Back to e mail form</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */

elseif (mail($recipient,$email,$message, $from)) {

} else {
echo "<h4>Can't send email</h4>";
}

?>

and this is the send script..

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

// Subject of email sent to you.
$subject = 'Results from Contact form';

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

// Where to redirect after form is processed.
$url = 'http://www.xxxxxxxxxxxxx.com/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
01-07-2014, 01:26 AM
save this on your server adit it to your email address then open it in a browser and a test message should be sent to you


<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>

<body>

<?php
$subject="test";
$to="myaddress@mail.com"; //edit to your own email
$message="Test message to see if 'mail()' is working";

mail($to, $subject,$message);

?>
</body>
</html>

vinnyvangogh
01-09-2014, 01:47 AM
<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Results from Contact form';

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

// Where to redirect after form is processed.
$url = 'http://www.xxxxxxxxxxxxx.com/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.'">';
?>


Sorry to be a pain.... The main was problem was found to be the new Windows 2003 server the IT added to the hosting to deal with the emails. The Spam filter was never tested against the forms output.

Snag is with messing about I seem to have fouled up the confirmation response.

// Where to redirect after form is processed.
$url = 'http://www.xxxxxxxxxxxxx.com/confirmation.html'; from the script above.

Can you see any reason why it won't work and only produces a blank page

This is from tests on my server so no spam filter distractions.

edbr
01-09-2014, 02:03 AM
if you open the age directly what happens?

vinnyvangogh
01-09-2014, 03:46 AM
if you open the age directly what happens?

Not sure which page you mean.

Fact is the script worked Ok for best part to 3 years and no issues.
After confirming the sodden spam filter was the cause and not the servers PHP settings - I put the form back together and uploaded it.

I have been at this all day! The form scripts is OK and returns all fields.
The one problem now is the redirect to " confirmation" page. I changes to the index and no different. Both pages in the webs root.
At this time when I send the form, the screen goes white - no content and the url showing is that of the form page! If I click Refresh.. it asks to send the form again and the screen stays white.

edbr
01-09-2014, 04:13 AM
not sure on this at all. give this a slight delay and see what happens

replace
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
with
echo '<META HTTP-EQUIV=Refresh CONTENT="3; URL='.$url.'">';
to give a 3 second delay before redirect

vinnyvangogh
01-09-2014, 05:52 AM
not sure on this at all. give this a slight delay and see what happens

replace
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
with
echo '<META HTTP-EQUIV=Refresh CONTENT="3; URL='.$url.'">';
to give a 3 second delay before redirect

Nothing just the same.
I did find a similar suggestion online..didnt work.
I also found on a forum an almost identical script and the same problem with the redirect. None worked and the OP never get a solution.. and that was 2009!
Which is not promising.

I removed the send results page from the root - and after sending the form.. the same white, blank page appears.... so is the form not actually activating the send results script??

The form returns are emailed out OK now... but the only solution to the blank page is back button back to the info page which precedes the first form.. and a link back to the main site index page... which is tedious for some.

edbr
01-09-2014, 06:53 AM
i just posted nonsense. again i dont see what mete refresh is giving any problems but try instead
header("Location:http://www.xxxxxxxxxxxxx.com/confirmation.html");

vinnyvangogh
01-09-2014, 10:04 PM
i just posted nonsense. again i dont see what mete refresh is giving any problems but try instead
header("Location:http://www.xxxxxxxxxxxxx.com/confirmation.html");

Hi,

Again... nothing works!

I also tried this -
You will want to use the PHP code

header("Location: http://www.example.com/");

most likely. What you can try doing is this:

$url = "refresh:5; url=http://www.".$_GET['site'];
header($url)

I used a valid domain name and inserted like this:-

header("Location: http://www.example.com/");
$url = "refresh:5; url=http://www.".$_GET['site'];
header($url)

Still the same white screen.

I have just changed the PHP setting on the server to V4. 1&1 UK had auto set v5.4 as preferred version, and suggest changes to scripts may need to be made!

Standing back after trying hints and tips from various website - none worked - I removed the send scripts page. I can send a form and it the email goes off OK.
With the send results page present or deleted the affect happens..ie a blank white screen - no redirect and the only way off the blank page is to back button to the form page.

I also notice that the various forums are not flooded with those PHP lost souls like me as - I presume - other hosting sites upgrade occasionally.

Going back, everything was OK and forgetting about the IT and his Spam filter - which has been taken of the recipient email addy... it does seem a PHP format change by 1&1 is affecting the forms operation.

How does the PHP industry deal with version upgrades and affected scripts??

edbr
01-10-2014, 01:33 AM
this is an odd one really. i dont know of any reason this should not still work, i will try to replicate it on one of my domains with 5.4 providing i get some time. can I see this online ? whats the URL?

as for php upgrades they can be annoying the 5.4 upgrade hits a lot of old scripts all in the name of progress. i manage a dating site that caused me some sleepless nights to make function again as it is based on an old script. some of the changes really weren't obvious.

an easy fix for now culd be to instaead of redirecting, offer the message thank you for emailing us noe go to....... and offer some links to you site . just a quick and dirty solution

edbr
01-10-2014, 01:54 AM
ok i tried and rested locally and on a live server and bot (5.4) and both worked.

here is the test
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>

<body>

<form action="" method="post">

<input name="message" type="text">message<br>
<input name="message2" type="text"><?php
if ($_POST['test']){
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Results from Contact form';

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

// Where to redirect after form is processed.
$url = 'http://www.00000000000000000000.com/index.php';

// 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.'">';
}
?>

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body>
<form action="" method="post">
<input name="test" type="submit" value="test">

</form>

</body>
</html>




try it , if this is not working then it is an issue on your server

vinnyvangogh
01-10-2014, 02:29 AM
Hi,

I assumed I was to strip out the PHP script from your test page.
If that is so... then not working!

Made a new page using everything your sent....uploaded.. tested... no working.

I have sent a request to 1&1 server support for advice.

My server is on PHPv4 clients is on PHP v5.4 both don't work.

Do you know what your server PHP version is?

I am taking a break from this ! And also let you go paddle in the sea. Over the weekend if nothing matures, I intend starting from scratch with a new set of pages and the original scripts from the 2009 web files.

As an aside do you know any free webspace that would allow PHP stuff. All I found under "free webs" are template based.

Thanks for your help and I will let you know the latest Monday.

edbr
01-10-2014, 03:06 AM
no dont strip out the code. i have diffents php versions, this was tested on 5.4 and as i said it worked

vinnyvangogh
01-10-2014, 10:56 PM
no dont strip out the code. i have diffents php versions, this was tested on 5.4 and as i said it worked

I put the page as you sent it on the server... this returned..
( Should I have split it into to pages shifting the bottom html page stuff??)
The document name you requested (/Test/.$url.) could not be found on this server. However, we found documents with names similar to the one you requested.

Will send you a link after I make a full test site.

For my feeble brain, the form delivery method sends the results to the PHP script - which should send the results to recipient and redirect back to a confirmation page ( in this case).
The results are sent out by the script, the failure seems to be the bottom end of the script that handles the redirect. I am confused that the server PHP is working for the forms results, so why not the rest of the redirect and does not throw up any error messages.

edbr
01-11-2014, 01:42 AM
from that error message ir seems it has tried to redirect but the path was not correct

edbr
01-11-2014, 02:10 AM
and the page waas compleste as the action is set to itself

vinnyvangogh
01-13-2014, 10:23 PM
Just to update the situation.
I had contacted the Hosting and explained that all had been Ok until the changed the Servers PHP versions. Stating that IMHO, has the for worked as far as checking the form field and actually sending the results by email - it should re-direct to main sites home page - but failed.
The short version is that say - although its outside "supports" remit they did check the form and consider that it "as advised prior to our recent PHP update, clients should check any PHP content complies to the current server settings".
Rather than spend any more of mine or your time, I have put a link after the script and any form sender can simply click the link or close the browser.

Again, I am indebted for the time and help you gave to help on this problem.
Thank you

jmichae3
01-29-2014, 09:42 AM
I looked at the 3rd post's code. you should also know that:


HTML5 doesn't use /> on void elements it only makes the browser look at it as bizarre (quirks mode probably)
XHTML5 and 1.0 and 1.1 require /> on void elements (singletons) or you get a big red syntax error from the browser
XHTML in any version requires single or double quotes on all attributes, and so does XML. HTML in any version doesn't care.
for future reference, boolean attributes as defined in the HTML5 whatwg.org (w3c) standard, must be coded without a value. for instance, instead of readonly="true" or disabled="true" you should put just readonly or disabled.

vinnyvangogh
05-18-2015, 06:05 AM
The script now looks like this:-
<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$name = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$telephone = $_POST['telephone'];
$order = $_POST['Order Number'];
$delivery = $_POST['Delivery Address '];
//add for each quty and item
$qyt01 = $_POST['QTY01'];
$item1 = $_POST['Item 01'];

$from = "From:$email \r\n";
$recipient= "xxxxxxxx@.com (xxxxxxxx@.com)";
//add $qyt02 - $item2 \n
$message = "order number $order \n
$name position $position \n
e mail address $email \n
telephone $telephone \n

$qyt01 - $item1 \n
text $info\n
Delivery Address $delivery \n
";

/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}

?>

And return this error:-
Parse error: syntax error, unexpected T_ELSEIF in /homepages/45/d91687222/htdocs/xxxxxxxxx.com/poform1.php on line 73



This form has stopped working! ( there is more in the thread trail above than on this post)

I have server options for PHP 5.6 - 5.5 - 5.4
The form originated around 2011.

Is it likely a a server PHP version issue?

I know basically nothing about PHP - so any suggestion would be appreciated.

edbr
05-18-2015, 06:21 AM
i dont see an if condition preceding the else if so try

if (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}