PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
nlimpag07
Forum Newbie
Posts: 10 Joined: Wed Jun 23, 2010 9:39 pm
Post
by nlimpag07 » Fri Jun 25, 2010 12:52 am
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..
Last edited by
Benjamin on Fri Jun 25, 2010 2:54 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Fri Jun 25, 2010 1:13 am
nlimpag07 wrote: Anyone can help me make this code functionable?
Depends. How is it not "functionable" right now?
nlimpag07
Forum Newbie
Posts: 10 Joined: Wed Jun 23, 2010 9:39 pm
Post
by nlimpag07 » Fri Jun 25, 2010 3:34 am
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...
rahulzatakia
Forum Commoner
Posts: 59 Joined: Fri Feb 05, 2010 12:01 am
Location: Ahmedabad
Post
by rahulzatakia » Fri Jun 25, 2010 4:32 am
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>
Last edited by
rahulzatakia on Fri Jun 25, 2010 5:23 am, edited 1 time in total.
amitdubey2
Forum Commoner
Posts: 48 Joined: Tue Apr 13, 2010 10:13 pm
Post
by amitdubey2 » Fri Jun 25, 2010 4:55 am
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
nlimpag07
Forum Newbie
Posts: 10 Joined: Wed Jun 23, 2010 9:39 pm
Post
by nlimpag07 » Mon Jun 28, 2010 12:00 am
Thanks a lot guys and also to you amit... can i ask for the validation amit?.. if u don't mind... thanks in advance..
amitdubey2
Forum Commoner
Posts: 48 Joined: Tue Apr 13, 2010 10:13 pm
Post
by amitdubey2 » Tue Jun 29, 2010 1:26 am
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
nlimpag07
Forum Newbie
Posts: 10 Joined: Wed Jun 23, 2010 9:39 pm
Post
by nlimpag07 » Thu Jul 08, 2010 1:17 am
Thanks amit... thank you very much...