I'm trying to collect some informations from an html form and send them to an e-mail using php. but all i get is a blank page. i looked to similar questions but i couldn't find the problem. this is my code:
<?php
if(isset($_POST['submit'])){
$Fname=$_POST['First'];
$Lname=$_POST['Last'];
$email=$_POST['email'];
$code=$_POST['countryCode'];
$phone=$_POST['phone'];
$Pname=$_POST['ProjectName'];
$Ptype=$_POST['ProjectType'];
$Pdisplay=$_POST['ProjectDisplay'];
$Powner=$_POST['ProjectOwner'];
$Plang=$_POST['ProjectLang'];
$Gender=$_POST['Gender'];
$Vitess=$_POST['Vitesse'];
$Style=$_POST['Style'];
$Duration=$_POST['Duration'];
$Script=$_POST['Script'];
$Cmnt=$_POST['Cmnt'];
$to='myAdredd';
$subject='Order';
$message="First Name: ".$Fname." "."Last Name: ".$Lname." "."\n"."E-mail: ".$email."\n"."Phone: ".$code." ".$phone."\n"."Project Name: ".$Pname."\n"."Project Type: ".$Ptype."\n"."Project Display: ".$Pdisplay."\n"."Owner: ".$Powner."\n"."Language: ".$Plang."\n"."Gender Voice: ".$Gender."\n"."Vitess: ".$Vitess."\n"."Style: ".$Style."\n"."Duration: ".$Duration."\n"."Script: "."\n\n".".$Script."."Message: ".$Cmnt."\n";
$headers="From: ".$email;
if(mail($to,$subject,$message,$headers)){
echo "sent";
}else{
echo "problem ";
}
}
?>
after submitting the form i don t see neither of: "sent" or "problem"
the site is hosted on bluehost
this is my first time ever using php
Use try
catch
for identify the error in script like-:
<?php
try{
if(isset($_POST['submit'])){
$Fname=$_POST['First'];
$Lname=$_POST['Last'];
$email=$_POST['email'];
$code=$_POST['countryCode'];
$phone=$_POST['phone'];
$Pname=$_POST['ProjectName'];
$Ptype=$_POST['ProjectType'];
$Pdisplay=$_POST['ProjectDisplay'];
$Powner=$_POST['ProjectOwner'];
$Plang=$_POST['ProjectLang'];
$Gender=$_POST['Gender'];
$Vitess=$_POST['Vitesse'];
$Style=$_POST['Style'];
$Duration=$_POST['Duration'];
$Script=$_POST['Script'];
$Cmnt=$_POST['Cmnt'];
$to='myAdredd';
$subject='Order';
$message="First Name: ".$Fname." "."Last Name: ".$Lname." "."\n"."E-mail: ".$email."\n"."Phone: ".$code." ".$phone."\n"."Project Name: ".$Pname."\n"."Project Type: ".$Ptype."\n"."Project Display: ".$Pdisplay."\n"."Owner: ".$Powner."\n"."Language: ".$Plang."\n"."Gender Voice: ".$Gender."\n"."Vitess: ".$Vitess."\n"."Style: ".$Style."\n"."Duration: ".$Duration."\n"."Script: "."\n\n".".$Script."."Message: ".$Cmnt."\n";
$headers="From: ".$email;
if(mail($to,$subject,$message,$headers)){
echo "sent";
}else{
echo "problem ";
}
}
}
catch(Exception $e){
echo $e;
}
?>
Make sure configure SMTP configuration in php.ini file before run
mail()
.
SMTP configuration look like-:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.