Jump to content

Urgent help please with form code in PHP


tonyaod

Recommended Posts

Help me I'm melting ..... Ok maybe not but I feel as if that would be far better than having to try and trouble shoot code i did not write and am not really sure about. In a nutshell I am stuck and have a customer jumping about wondering why their site won't work.  ???

 

There are a few forms on this website which do not work. I am an ASP coder not PHP so am not overly sure if this code should work ok. BTW I did not create the site I am simply the administrator for the ISP (who also happens to do some web programming & development) - hence why the job has been handed to me.

 

It is the same code used to process two forms on the site. One is a contact form the other an information gathering form.

 

My guess is the code should iterate through all the fields in the form returning the values of all fields into an email which is sent to $my_email = "[email protected]".

 

However the emails are not coming through & since I am not a PHP expert am not sure why.

 

Can anyone read this code and see any obvious errors? Or suggest a possible reason why the code is not working or better code that I could use that will do the same thing.  :D

 

<?php

 

$my_email = "[email protected]";

$continue = "/formsent.html";

if ($_SERVER['REQUEST_METHOD'] != "POST"){exit;}

$disallowed_name = array(':',';',"'",'"','=','(',')','{','}','@');

foreach($disallowed_name as $value)

{

 

if(stristr($_POST[Name],$value)){header("location: $_SERVER[HTTP_REFERER]");exit;}

 

}

 

$disallowed_email = array(':',';',"'",'"','=','(',')','{','}');

 

foreach($disallowed_email as $value)

{

 

if(stristr($_POST,$value)){header("location: $_SERVER[HTTP_REFERER]");exit;}

 

}

 

$message = "";

 

while(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$messag e = $message . "$key: $value\n\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}

 

$message = $message . "-- \n Head Office

\n OPM House

\n Elgar Business Centre

\n Moseley Road

\n Hallow

\n Worcester

\n WR2 6NJ

\n

\n T. 01905 641 404

\n F. 01905 641 405

\n e. [email protected]

\n w. opm-mortgages.co.uk";

$message = stripslashes($message);

 

$subject = "OPM Mortgages Email";

$headers = "From: " . $_POST['Email'] . "\n" . "Return-Path: " . $_POST['Email'] . "\n" . "Reply-To: " . $_POST['Email'] . "\n";

 

mail($my_email,$subject,$message,$headers);

 

?>

Link to comment
https://forums.phpfreaks.com/topic/57454-urgent-help-please-with-form-code-in-php/
Share on other sites

$headers = "From: " . $_POST['Email'] . "\r\n" . "Return-Path: " . $_POST['Email'] . "\r\n" . "Reply-To: " . $_POST['Email'] . "\r\n";

 

Headers generally require the "\r\n" not just the "\n"

 

www.php.net/mail

 

Also mail tends to get filtered as junk that come from apache so check the junk mail.

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.