Jump to content

PHP Form is sending blank emails


mhann90

Recommended Posts

Hello, 

 

I don't have much knowledge about coding, and so I use a WYSIWYG builder for my website. 

 

I had a PHP form working perfectly, until I recently changed the design on my website. It is now successfully sending an email to me, but all the fields are blank. I am not sure where I have gone wrong. If anyone could please help me to sort it out?

 

This is the code from my form:

<div id="wb_Form2" style="position:absolute;width:744px;height:838px;">
<form name="query" method="post" action="thank-you.php" enctype="text/plain" id="Form2" onsubmit="return Validatequery(this)">
<div id="wb_Text10" style="position:absolute;left:47px;top:208px;width:229px;height:15px;text-align:right;z-index:5;">
<span style="color:#3C3C3C;font-family:Arial;font-size:12px;">Describe your ideal journey</span><span style="color:#FF0000;font-family:Arial;font-size:12px;">*</span><span style="color:#3C3C3C;font-family:Arial;font-size:12px;">:</span></div>
<div id="wb_Text5" style="position:absolute;left:45px;top:52px;width:233px;height:15px;text-align:right;z-index:6;">
<span style="color:#3C3C3C;font-family:Arial;font-size:12px;">Which tour caught your eye?</span><span style="color:#FF0000;font-family:Arial;font-size:12px;">*</span><span style="color:#3C3C3C;font-family:Arial;font-size:12px;">:</span></div>
<div id="wb_Text6" style="position:absolute;left:2px;top:91px;width:276px;height:15px;text-align:right;z-index:7;">
<span style="color:#3C3C3C;font-family:Arial;font-size:12px;">Your preferred level of accommodation</span><span style="color:#FF0000;font-family:Arial;font-size:12px;">*</span><span style="color:#3C3C3C;font-family:Arial;font-size:12px;">:</span></div>
<div id="wb_Text7" style="position:absolute;left:45px;top:129px;width:233px;height:15px;text-align:right;z-index:8;">
<span style="color:#3C3C3C;font-family:Arial;font-size:12px;">Who'll be travelling?</span><span style="color:#FF0000;font-family:Arial;font-size:12px;">*</span><span style="color:#3C3C3C;font-family:Arial;font-size:12px;">:</span></div>
<div id="wb_Text8" style="position:absolute;left:54px;top:168px;width:224px;height:15px;text-align:right;z-index:9;">
<span style="color:#3C3C3C;font-family:Arial;font-size:12px;">When will you travel to India?</span><span style="color:#FF0000;font-family:Arial;font-size:12px;">*</span><span style="color:#3C3C3C;font-family:Arial;font-size:12px;">:</span></div>
<div id="wb_Text13" style="position:absolute;left:82px;top:472px;width:415px;height:22px;z-index:10;text-align:left;">
<span style="color:#447FC3;font-family:Arial;font-size:19px;"><strong>Your Details (Step 2 of 2)</strong></span><span style="color:#97731D;font-family:'Noto Serif';font-size:17px;"><strong> </strong></span><span style="color:#808080;font-family:Arial;font-size:13px;"><em>required</em></span></div>
<div id="wb_Text1" style="position:absolute;left:101px;top:520px;width:177px;height:15px;text-align:right;z-index:11;">
<span style="color:#3C3C3C;font-family:Arial;font-size:12px;">Please tell us your name</span><span style="color:#FF0000;font-family:Arial;font-size:12px;">*</span><span style="color:#3C3C3C;font-family:Arial;font-size:12px;">:</span></div>
<div id="wb_Text2" style="position:absolute;left:83px;top:558px;width:195px;height:15px;text-align:right;z-index:12;">
<span style="color:#3C3C3C;font-family:Arial;font-size:12px;">and your email address</span><span style="color:#FF0000;font-family:Arial;font-size:12px;">*</span><span style="color:#3C3C3C;font-family:Arial;font-size:12px;">:</span></div>
<div id="wb_Text3" style="position:absolute;left:87px;top:597px;width:191px;height:15px;text-align:right;z-index:13;">
<span style="color:#3C3C3C;font-family:Arial;font-size:12px;">Where are you from?</span><span style="color:#FF0000;font-family:Arial;font-size:12px;">*</span><span style="color:#3C3C3C;font-family:Arial;font-size:12px;">:</span></div>
<div id="wb_Text9" style="position:absolute;left:66px;top:636px;width:211px;height:15px;text-align:right;z-index:14;">
<span style="color:#3C3C3C;font-family:Arial;font-size:12px;">Lastly, your telephone number</span><span style="color:#FF0000;font-family:Arial;font-size:12px;">*</span><span style="color:#3C3C3C;font-family:Arial;font-size:12px;">:</span></div>
<div id="wb_Text12" style="position:absolute;left:67px;top:8px;width:415px;height:22px;z-index:15;text-align:left;">
<span style="color:#447FC3;font-family:Arial;font-size:19px;"><strong>Your Travel Plans (Step 1 of 2)</strong></span><span style="color:#97731D;font-family:Arial;font-size:19px;"><strong> </strong></span><span style="color:#808080;font-family:Arial;font-size:13px;"><em>required</em></span></div>
<select name="tour" size="1" id="$tr" style="position:absolute;left:290px;top:48px;width:304px;height:29px;z-index:16;">
<option value="$tr">Select one of our sample itineraries...</option>
<option>Classic Rajasthan</option>
<option>Jaisalmer Rajasthan </option>
<option>Mandawa Rajasthan </option>
<option>Oberoi Hotel Luxury Rajasthan </option>
<option>Oberoi, Leela & Taj Rajasthan </option>
<option>Rajasthan without the Taj Mahal</option>
<option>Rajasthan with Kerala </option>
<option>Rajasthan with Pushkar Fair</option>
<option>Rajasthan with Varanasi</option>
<option>None... I want to start from scratch</option>
</select>
<select name="hotels" size="1" id="$ht" style="position:absolute;left:290px;top:88px;width:385px;height:29px;z-index:17;">
<option>Select your preferred level...</option>
<option>Premium 5* (The very best hotels in the region)</option>
<option>5* (Luxury with a wide range of facilities)</option>
<option>4* (High standard hotels)</option>
<option>3* (Best value hotels)</option>
<option>Mixed Categories (please share further details in the description box)</option>
<option>I'm not sure</option>
</select>
<select name="pax" size="1" id="$px" style="position:absolute;left:290px;top:127px;width:142px;height:29px;z-index:18;">
<option>Couple</option>
<option>Family / Group</option>
<option>Solo</option>
</select>
<input type="text" id="$dt" style="position:absolute;left:290px;top:165px;width:258px;height:17px;line-height:17px;z-index:19;" name="date" value="">
<textarea name="describe" id="$ds" style="position:absolute;left:290px;top:209px;width:312px;height:195px;z-index:20;" rows="12" cols="59" placeholder="The more you can share, the better! Eg. How long would you like to stay? What would you like to do? Is there anything in particular that you really want to experience? Is it your first time to India? If you're traveling as a group or family, how many people? Please tell us as much information as you can."></textarea>
<select name="title" size="1" id="$tl" style="position:absolute;left:290px;top:515px;width:81px;height:29px;z-index:21;">
<option>Title...</option>
<option>Mr</option>
<option>Mrs</option>
<option>Ms</option>
<option>Miss</option>
<option>Dr</option>
</select>
<input type="text" id="$nm" style="position:absolute;left:378px;top:515px;width:177px;height:17px;line-height:17px;z-index:22;" name="name" value="" placeholder="First Name">
<input type="text" id="$sn" style="position:absolute;left:575px;top:515px;width:139px;height:17px;line-height:17px;z-index:23;" name="surname" value="" placeholder="Last Name">
<input type="text" id="$em" style="position:absolute;left:290px;top:553px;width:312px;height:17px;line-height:17px;z-index:24;" name="email" value="" placeholder="Email">
<input type="text" id="$fr" style="position:absolute;left:290px;top:593px;width:188px;height:17px;line-height:17px;z-index:25;" name="from" value="" placeholder="Country">
<input type="text" id="$tp" style="position:absolute;left:290px;top:632px;width:188px;height:17px;line-height:17px;z-index:26;" name="telephone" value="" placeholder="Telephone">
<input type="submit" id="Button2" name="Submit" value="SEND ENQUIRY" style="position:absolute;left:290px;top:709px;width:180px;height:50px;z-index:27;">
<div id="wb_Text14" style="position:absolute;left:290px;top:776px;width:348px;height:42px;z-index:28;text-align:left;">
<span style="color:#808080;font-family:Arial;font-size:11px;">We will never share your personal information with any third parties, nor send you unsolicited email. We will only call you in relation to your query. </span></div>
</form>
</div>

and this is the code on my thank-you page which has the PHP details on it. The only change I have made here is to delete my SMTP password and username:

<?php

  if ($_SERVER['REQUEST_METHOD'] != 'POST'){
    header('Refresh: 0; URL=/index.html');
    exit;
  }

	$path = dirname( __FILE__ );
	include $path.'/class.phpmailer.php';

	$tr = $_POST['tour'];
	$ht = $_POST['hotels'];
	$px = $_POST['pax'];
	$dt = $_POST['date'];
	$ds = $_POST['describe'];
	$tl = $_POST['title'];
	$nm = $_POST['name'];
	$sn = $_POST['surname'];
	$em = $_POST['email'];
	$fr = $_POST['from'];
	$tp = $_POST['telephone'];
		

	$message = 	"Which tour caught your eye? = " . $tr . "<br />" .
			"Your preferred level of accommodation = " . $ht . "<br />" .
			"Who'll be travelling? = " . $px . "<br />" .
			"When will you travel to India? = " . $dt . "<br />" .
			"Describe your ideal journey = " . $ds . "<br />" .
			"<hr>" .
			"Name = " . $tl . " " . $nm . " " . $sn . "<br />" .
			"Email = " . $em . "<br />" .
			"From = " . $fr . "<br />" .
			"Telephone = " . $tp . "<br />";
	
	
	$mail = new PHPMailer();
	
	$mail->IsSMTP();                                      // set mailer to use SMTP
	$mail->Host = "mail.rajasthantourpackage.co";  // specify main and backup server cp-2.webhostbox.net
	$mail->SMTPAuth = true;     // turn on SMTP authentication
	$mail->Username = "query@rajasthantourpackage.co";  // SMTP username
	$mail->Password = "password"; // SMTP password
	
	$mail->From = "query@rajasthantourpackage.co";
	$mail->FromName = "Web Enquiry";
	$mail->AddAddress("my email");
	$mail->AddAddress("second email");
	
	$mail->WordWrap = 50;                                 // set word wrap to 50 characters
	$mail->IsHTML(true);                                  // set email format to HTML
	
	$mail->Subject = "Web Enquiry from " . $tl . " ". $nm . " " . $sn;
	$mail->Body    = $message;
	
	if(!$mail->Send())
	{
	   echo "Message could not be sent.>";
	   //echo "Mailer Error: " . $mail->ErrorInfo;
	   exit;
	}
?>

Thank you so much if you can help. Tearing my hair out!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.