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
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." <br><br> \
\r Telephone: ".$ct_phone:’’);
if(isset($_SESSION[’_request’])): unset($_SESSION[’_request’]); endif;
$_SESSION[‘SITE_RSP’] = ‘Message sent. You will get a response shortly.’;
if(!empty($_SESSION[‘SITE_RSP’])): echo $_SESSION[‘SITE_RSP’]; endif; ?>
<?php echo (!empty($_SESSION['_request']['ct_message'])?$_SESSION['_request']['ct_message']:'') ?>
OMG! a bit long…i hope i get the application on time. thanks a million
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
After you have done this, check out for this line in your code window of the form you designedand insert the name of the php file u created in between the " "
wow! this is really short! how come the other one is that long? any difference?
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.
someday, i’ll learn that, thanks
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?
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.
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.
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?
@ 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
|Your company's name|
|Your e-mail address|
|Your phone number|
| || |
| || |
i think this page is rendering the form oh! its not showing the code, let me know if u can see d code.
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.
thanks a million. noted
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?
There are many reasons why your email may not get sent.
- Your hosting company may belimiting the number of emails you send.
- There was an error before the mail function was called.
- 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”;
i have not even sent up to ten mails!!!
i dont understand jare, i dont write php, just need help