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 = "chris.h@zookx.com".

 

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 = "chris.h@zookx.com";

$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. sales@opm-mortgages.co.uk

\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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.