submit.php script


#1

Need a php submit script for my site. please dont refer me to google!!! i got tired, just kindly send me a working code. trust you guys. thanks in advance


#2

I copied this from one of my old script. U might need to do some tweak…

<!--?php if(!empty($_POST['ct_send'])): header("Location: contact.php"); //or chnage to the page u are calling from
$ct_name = $_POST['ct_name'];
$ct_email = $_POST['ct_email'];
$ct_phone = $_POST['ct_phone'];
$ct_subject = $_POST['ct_subject'];
$ct_message = $_POST['ct_message'];

foreach($_POST as $__key=-->$__request):
	if(isset($$__key)): $_SESSION['_request'][$__key] = $_POST[$__key]; endif;
endforeach;

if(empty($ct_name) || empty($ct_email) || empty($ct_subject) || empty($ct_message)):
	$_SESSION['SITE_RSP'] = '<div id="rsp_div" class="error_set">Please fill the required fields appropriately.</div>'; die();
elseif(SITE_WIPER::__validateEmail($ct_email) !== true):
	$_SESSION['SITE_RSP'] = '<div id="rsp_div" class="error_set">It seems you\\'ve entered an invalid email address format!</div>'; die();
else:
			
	$to = "[email protected]";
	$from = "\"".$ct_name."\"<".$ct_email.">";
	$subject = $ct_subject;
	$headers = 'MIME-Version: 1.0' . "\\r\

";
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . "\r
";
$headers .= 'From: ’ .$from. "\r
";
$headers .= "Reply-To: ".$ct_email;

	$message = 'From:'.$ct_name.' - '.$ct_email."&nbsp; <br><br> \

\r".$ct_message.(!empty($ct_phone)?"


\r Telephone: ".$ct_phone:’’);
mail($to,$subject,$message,$headers);
if(isset($_SESSION[’_request’])): unset($_SESSION[’_request’]); endif;
$_SESSION[‘SITE_RSP’] = ‘

Message sent. You will get a response shortly.
’;
die();
endif;
die();
endif;

if(!empty($_SESSION[‘SITE_RSP’])): echo $_SESSION[‘SITE_RSP’]; endif; ?>

    

Fullname :         

        

E-mail :         

        

Telephone :         

        

Subject :         

        

      <?php echo (!empty($_SESSION['_request']['ct_message'])?$_SESSION['_request']['ct_message']:'') ?>    

        
                

`


#3

OMG! a bit long…i hope i get the application on time. thanks a million


#4

This can help you out
Firstly design the form with the necessary fields for the inputs you need to capture type the following php code in a new page and save it with any name u want with .php as the extension

<?php $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $message=$_POST['message']; (Note: u can add as many fields as possible to the above based on the numbers of fields you have in the form you designed) echo ("Your message was successfully sent!"); $ToEmail = "the email you want the form to be submitted"; $ToSubject = "Message title"; $EmailBody = "Name: $name\ Email: $email\ Phone: $phone\ Message: $message\ "; $Message = $EmailBody; $headers .= 'MIME-Version: 1.0' . "\\r\ "; $headers .= "Content-type: text; charset=iso-8859-1\\r\ "; $headers .= "From:".$email."\\r\ "; mail($ToEmail,$ToSubject,$Message, $headers); ?>

After you have done this, check out for this line in your code window of the form you designed

and insert the name of the php file u created in between the " "

#5

wow! this is really short! how come the other one is that long? any difference?


#6

The code is just meant to submit the information supplied, you must have validated the form. The longer one u have earlier has the validation included in the scripts.
Cheers


#7

someday, i’ll learn that, thanks


#8

Adeleke: i finally try the code, and it works perfectly except that the message part of the form was not delivered to my mail!!! what could be d problem?


#9

Samson: is it that the message got delivered and the message body was empty?
if the mail was not delivered at then check the “$ToEmail” body of the script and make sure you type the mail address within the braces"". $ToEmail = “the email address”; if the message is not showing then check your then check this part $message=$_POST[‘message’]; , make sure the names declared here is the same with the field name on the form. Trust U will get it right this time.


#10

The message was delivered to my mail but “the message body” was empty, all other info was delivered except that part…i mean d e-mail, tel and other parts were delivered except the message.


#11

Samson: can u paste the code between your so that I can look at it or how did you declare your fields on the webpage?


#12
<?php $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $message=$_POST['message']; echo ("Your message was successfully sent!"); $ToEmail = "[email protected]"; $ToSubject = "Message title"; $EmailBody = "Name: $name\ Email: $email\ Phone: $phone\ Message: $message\ "; $Message = $EmailBody; $headers .= 'MIME-Version: 1.0' . "\\r\ "; $headers .= "Content-type: text; charset=iso-8859-1\\r\ "; $headers .= "From:".$email."\\r\ "; mail($ToEmail,$ToSubject,$Message, $headers); ?>

#13

@ Samson: what you have just posted here is the php script, I need to c ur form fields because if the declared form fields are not the same with the declaration in php code the delivery may not be right. So let us c your form. Thanks


#14


Your name
Your company's name
Your e-mail address
Your phone number
Your message
&nbsp; &nbsp;
&nbsp;
Security Code
&nbsp; &nbsp;
&nbsp;

#15

i think this page is rendering the form oh! its not showing the code, let me know if u can see d code.


#16

Samson; from what i can see from your code there is no where you declared the message field what you had is “msg” instead of “message” so it is either you change it to “message” in your form or you change it to “msg” in your php code and it will work. Trust you will get it right this time.


#17

thanks a million. noted


#18

i think d code stops working after some time, abi? because when i tryed it now, my mail was not delivered. any reason for that?


#19

There are many reasons why your email may not get sent.

  1. Your hosting company may belimiting the number of emails you send.
  2. There was an error before the mail function was called.
  3. Maybe you have been blacklisted and your mails are going into the spam folder.

To be sure you have no problem on your end, you could add a bcc header to the mail copying yourself. The mail function also returns a boolean value, so you could check the value of the mail function call like this.
if ( mail($ToEmail,$ToSubject,$Message, $headers) ) echo “Mail sent”;


#20

i have not even sent up to ten mails!!!

i dont understand jare, i dont write php, just need help