Page 1 of 1
PHP Mail Problem
Posted: Fri Jun 25, 2010 12:52 am
by nlimpag07
Hi!! i am stuck in this problem... i almost viewed the whole google...

. but still cant get my code functionable...
i i want to send email using php. Try to look ..
Code: Select all
<?
//Check whether the submission is made
if(isset($Send)){
$username = 'username';
$txtSub = 'sub';
$lastname = 'Lname';
$phone = 'number';
$txtEmailfrm = 'Umail';
$msg = 'msg';
$email_To= "noellimpag@yahoo.com";
$txtMsg =
"Someone Sends you an email.../n
Mailer Name: $username $lastname /n
Mailer Address: $add /n
Mailer Number: $phone /n/n
$msg
"
//Declarate the necessary variables
$mail_to=$email_To;
$mail_from=$txtEmailfrm;
$mail_sub=$txtSub;
$mail_mesg=$txtMsg;
//Check for success/failure of delivery
mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from/r/nReply-to:$mail_from")
?>
<form method="post" action="" onSubmit="return ValidationForm()">
<div class="formtitle">Your Name*:</div><div class="formentry"><input name="username" type="text"class="formcolor" ></div>
<div class="formtitle">Last Name*:</div><div class="formentry"><input name="Lname" type="text"class="formcolor"></div>
<div class="formtitle"></div>
<div class="formentry"></div>
<div class="formtitle">Your E-mail*:</div><div class="formentry"><input name="Umail" type="text"class="formcolor"></div>
<div class="formtitle">Phone Number*:</div><div class="formentry"><input name="number" type="text"class="formcolor"></div>
<div class="formtitle">Subject*:</div><div class="formentry"><input name="sub" type="text"class="formcolor"></div>
<div class="msglabel"><div class="formtitle">Message:</div></div><div class="msgsize"><textarea name="msg" cols="30" rows="6" class="formcolor">asdasdasdasd</textarea></div>
<div class="reg"><input name="Send" type="submit" id="Send" value="Send"class="formcolor" ></div>
</form>
Pls.. Anyone can help me make this code functionable?
Replies Really needed..
Re: PHP Mail Problem
Posted: Fri Jun 25, 2010 1:13 am
by requinix
nlimpag07 wrote:Anyone can help me make this code functionable?
Depends. How is it not "functionable" right now?
Re: PHP Mail Problem
Posted: Fri Jun 25, 2010 3:34 am
by nlimpag07
Thanks for editing... and sorry i don't use the php syntax..
Yup its not functionable(may not the right word). I had uploaded it on my server and try it but it didn't send an email...
Re: PHP Mail Problem
Posted: Fri Jun 25, 2010 4:32 am
by rahulzatakia
Hi, there was many syntax errors in your code so i have corrected them. Check out the following code. Still if you have any problem let us know.
Code: Select all
<?
//Check whether the submission is made
if(isset($_POST['Send'])){
$username = $_POST['username'];
$txtSub = $_POST['sub'];
$lastname = $_POST['Lname'];
$phone = $_POST['number'];
$txtEmailfrm = $_POST['Umail'];
$msg = $_POST['msg'];
$email_To= "noellimpag@yahoo.com";
$txtMsg =
"Someone Sends you an email.../n
Mailer Name: $username $lastname /n
Mailer Number: $phone /n/n
$msg";
//Declarate the necessary variables
$mail_to=$email_To;
$mail_from=$txtEmailfrm;
$mail_sub=$txtSub;
$mail_mesg=$txtMsg;
//Check for success/failure of delivery
mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from/r/nReply-to:$mail_from");
}
?>
<form method="post" action="" onSubmit="return ValidationForm()">
<div class="formtitle">Your Name*:</div><div class="formentry"><input name="username" type="text"class="formcolor" ></div>
<div class="formtitle">Last Name*:</div><div class="formentry"><input name="Lname" type="text"class="formcolor"></div>
<div class="formtitle"></div>
<div class="formentry"></div>
<div class="formtitle">Your E-mail*:</div><div class="formentry"><input name="Umail" type="text"class="formcolor"></div>
<div class="formtitle">Phone Number*:</div><div class="formentry"><input name="number" type="text"class="formcolor"></div>
<div class="formtitle">Subject*:</div><div class="formentry"><input name="sub" type="text"class="formcolor"></div>
<div class="msglabel"><div class="formtitle">Message:</div></div><div class="msgsize"><textarea name="msg" cols="30" rows="6" class="formcolor">asdasdasdasd</textarea></div>
<div class="reg"><input name="Send" type="submit" id="Send" value="Send"class="formcolor" ></div>
</form>
Re: PHP Mail Problem
Posted: Fri Jun 25, 2010 4:55 am
by amitdubey2
hi,
just said..there are many syntax error..in your code..
You may use the following code..it is not doing the validation part ..but let me know if you want validation.
here is the code..
Code: Select all
<?php
//Check whether the submission is made
if(isset($_POST['submit'])){
$username = $_POST['username'];
$txtSub = $_POST['sub'];
$lastname = $_POST['Lname'];
$phone = $_POST['number'];
$txtEmailfrm = $_POST['Umail'];
$msg = $_POST['msg'];
$email_To= "noellimpag@yahoo.com";
$txtMsg ="Someone Sends you an email...\n Mailer Name:$username $lastname \n Mailer Number: $phone \n message: $msg \n";
//Declarate the necessary variables
$mail_to=$email_To;
$email=$txtEmailfrm;
$mail_sub=$txtSub;
$mail_mesg=$txtMsg;
$headers = "From: $email\r\n" ."X-Mailer: php";
//Check for success/failure of delivery
if(mail($mail_to,$mail_sub,$mail_mesg,$headers))
{
echo"message sent";
}
else
{
echo"Not sent";
}
}
?>
<form method="post" action="">
<div class="formtitle">Your Name*:</div><div class="formentry"><input name="username" type="text"class="formcolor" ></div>
<div class="formtitle">Last Name*:</div><div class="formentry"><input name="Lname" type="text"class="formcolor"></div>
<div class="formtitle"></div>
<div class="formentry"></div>
<div class="formtitle">Your E-mail*:</div><div class="formentry"><input name="Umail" type="text"class="formcolor"></div>
<div class="formtitle">Phone Number*:</div><div class="formentry"><input name="number" type="text"class="formcolor"></div>
<div class="formtitle">Subject*:</div><div class="formentry"><input name="sub" type="text"class="formcolor"></div>
<div class="msglabel"><div class="formtitle">Message:</div></div><div class="msgsize"><textarea name="msg" cols="30" rows="6" class="formcolor">asdasdasdasd</textarea></div>
<div class="reg"><input name="submit" type="submit" id="Send" value="submit"class="formcolor" ></div>
</form>
cheers..
amit

Re: PHP Mail Problem
Posted: Mon Jun 28, 2010 12:00 am
by nlimpag07
Thanks a lot guys and also to you amit... can i ask for the validation amit?.. if u don't mind... thanks in advance..
Re: PHP Mail Problem
Posted: Tue Jun 29, 2010 1:26 am
by amitdubey2
hi nlimpag07,
This is the code with validation .. it will work for you.
Code: Select all
<SCRIPT SRC="translate.js"></SCRIPT>
<SCRIPT LANGUAGE="javascript">
function checkfield(loginform)
{
ok=true
if(loginform.username.value=="")
{
alert("Please Enter Your First Name.")
loginform.username.focus()
ok=false
}
else if(loginform.Lname.value=="")
{
alert("Please Enter Your Last Name.")
loginform.Lname.focus()
ok=false
}
else if(loginform.number.value=="")
{
alert("Please Enter your contact Number.")
loginform.number.focus()
ok=false
}
else if(loginform.subject.value=="")
{
alert("Please Enter the subject.")
loginform.subject.focus()
ok=false
}
else if (loginform.msg.value == "")
{
alert("Please leave some message.");
loginform.msg.focus();
ok=false
}
else if (loginform.email.value == "")
{
alert("Please enter a value for the email field.");
loginform.email.focus();
ok=false
}
else if (!isEmailAddr(loginform.email.value))
{
alert("Please enter a complete email address in the form: yourname@yourdomain.com");
loginform.email.focus();
ok=false
}
return ok
}
function isEmailAddr(email)
{
var result = false
var theStr = new String(email)
var index = theStr.indexOf("@");
if (index > 0)
{
var pindex = theStr.indexOf(".",index);
if ((pindex > index+1) && (theStr.length > pindex+1))
result = true;
}
return result;
}
</SCRIPT>
<?php
//Check whether the submission is made
if(isset($_POST['submit'])){
$username = $_POST['username'];
$txtSub = $_POST['subject'];
$lastname = $_POST['Lname'];
$phone = $_POST['number'];
$txtEmailfrm = $_POST['email'];
$msg = $_POST['msg'];
$email_To= "noellimpag@yahoo.com";
$txtMsg ="Someone Sends you an email...\n Mailer Name:$username $lastname \n Mailer Number: $phone \n message: $msg \n";
//Declarate the necessary variables
$mail_to=$email_To;
$email=$txtEmailfrm;
$mail_sub=$txtSub;
$mail_mesg=$txtMsg;
$headers = "From: $email\r\n" ."X-Mailer: php";
//Check for success/failure of delivery
if(mail($mail_to,$mail_sub,$mail_mesg,$headers))
{
echo"message sent";
}
else
{
echo"Not sent";
}
}
?>
<form name="loginform" method="post" action="" ONSUBMIT="return checkfield(loginform)">
<INPUT NAME="required" TYPE="hidden" VALUE="uname,Lname,email,subject,number,msg">
<INPUT NAME="sort" TYPE="hidden" VALUE="uname,Lname,email,subject,number,msg">
<div class="formtitle">Your Name*:</div><div class="formentry"><input name="username" type="text"class="formcolor" ></div>
<div class="formtitle">Last Name*:</div><div class="formentry"><input name="Lname" type="text"class="formcolor"></div>
<div class="formtitle"></div>
<div class="formentry"></div>
<div class="formtitle">Your E-mail*:</div><div class="formentry"><input name="email" type="text"class="formcolor"></div>
<div class="formtitle">Phone Number*:</div><div class="formentry"><input name="number" type="text"class="formcolor"></div>
<div class="formtitle">Subject*:</div><div class="formentry"><input name="subject" type="text"class="formcolor"></div>
<div class="msglabel"><div class="formtitle">Message:</div></div><div class="msgsize"><textarea name="msg" cols="30" rows="6" class="formcolor"></textarea></div>
<div class="reg"><input name="submit" type="submit" id="Send" value="submit"class="formcolor" ></div>
</form>
Feel free to contact if you have problem in this.
Cheers
amit
Re: PHP Mail Problem
Posted: Thu Jul 08, 2010 1:17 am
by nlimpag07
Thanks amit... thank you very much...