Sendmail form not working properly..probably something simple

Can anyone help me rectify this sendmail.php form…?

In the sendmail.php file (attached), I need to change the form id ‘website’ to ‘pickup-addr’ but everytime I try it stops the emails from going/coming altogether.

When I leave ‘website’ in the sendmail.php file, it goes but this is what shows up in the body of the email:

This message was send from:

by: Janessa Mc Kell

Email: janessa.mckell@gmail.com

Pickup Details:

Subject: airport run

Text of message: 1 person with 4 pcs luggage

Sorry - but I don’t normally download somebody’s zip file (or full scripts for that matter). A bit of paranoia.

Of course, you could make it easier for us to help if you JUST posted the area of code that is causing your problem

Hi ginerjm, no problem, here is the code for the two files:

…contacts.html

<div class="main">
  <div class="row-nav">
    <nav id="navigation">
      <ul style="text-align:center">
        <li><a href="home.html">about us</a></li>
        <li><a href="services.html">services</a></li>
        <li class="active"><a href="contacts.html">contact us</a></li>
      </ul>
    </nav>
    <div class="clear"></div>
    <!--/ navigation--> 
  </div>
  <section  id="content"  class="clearfix">
    <div class="box-map">
      <h2>Our Location</h2>
      
      <div class="overflow">
        <address>
        <span><strong>Call Ron Lewis at:1-868-342-6103</strong></span>
        <strong>Email:</strong><a href="mailto:wellgetuthere@gmail.com"> wellgetuthere@gmail.com</a></span>
        </address>
      </div>
    </div>
    <div class="box-form">
      <h2>Contact Form</h2>
      <div class="box error_box" style="display:none;">
        <p> Your message has not been sent successfully. There was an error on the page! </p>
      </div>
      <div class="box info_box" style="display:none;">
        <p> Thank you! Your message has been sent successfully. </p>
      </div>
      <form action="#" method="post" id="contactform">
        <fieldset>
          <div class="box-left1">
            <input type="text" name="name" id="name" placeholder="Your Name (required)" />
            <input type="text" name="email" id="email" placeholder="Your E-mail (required)" />
            <p><strong>Do you need to book us? Please give details. <br />(NB: 50% downpayment required on all drops)</strong></p>
            <input type="text" name="pickup-addr" id="pickup-addr" placeholder="Pickup Address" />
            <input type="text" name="date" id="date" placeholder="Enter Date and Time of Pickup" />
          </div>
          <div class="box-right1">
            <input type="text" name="subject" id="subject" placeholder="Subject" />
            <textarea name="message" id="message" placeholder="Send more details if you're booking us or if not, you may also send a messsage here."></textarea>
            <input id="formsend" type="submit" value="send" />
            <input type="reset" value="Clear" />
          </div>
          <div class="clear"></div>
        </fieldset>
        <fieldset>
          <div>
            <input type="hidden" value="janessa.mckell@gmail.com" id="contactemail" name="contactemail"  />
          </div>
          <div>
            <input type="hidden" value="php/sendmail.php" id="contacturl" name="contacturl"  />
          </div>
          <div class="loading"></div>
        </fieldset>
      </form>
    </div>
    <!--/ contform--> 
    
  </section>
</div>

…and sendmail.php:

<?php
if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'form'){
	if (isset($_REQUEST['contactemail'])){ $mailTo = $_REQUEST['contactemail']; }
	if (isset($_REQUEST['name'])){ $mailFromName = $_REQUEST['name']; }
	if (isset($_REQUEST['email'])){ $mailFromEmail = $_REQUEST['email']; }
	if (isset($_REQUEST['pickup-addr'])){ $website = $_REQUEST['pickup-addr']; }
	if (isset($_REQUEST['date'])){ $website = $_REQUEST['date']; }
	if (isset($_REQUEST['subject'])){ $subject = $_REQUEST['subject']; }
	if (isset($_REQUEST['message'])){ $message = $_REQUEST['message']; }
	if (isset($_REQUEST['mywebsite'])){ $mailFromWebsite = $_REQUEST['mywebsite']; }
	
	$msg = "This message was sent from: $mailFromWebsite \
\
by: $mailFromName \
\
Email: $mailFromEmail \
\
Pickup Details: $website \
\
Subject: $subject \
\
Text of message: $message";
	$headers = "MIME-Version: 1.0\\r\
 Content-type: text/html; charset=utf-8\\r\
 From: $mailFromEmail\\r\
 Reply-To: $mailFromEmail";
	
	mail($mailTo, $subject, $msg, $headers);
}
?>

Show us the exact area that has the problem and tell us exactly what you are changing. I see no exact word ‘website’ in your script nor any reference in the code to a “form id”. Hard to help if you don’t show us the change you are making. Sorry to be such a pia, but you are not really making much sense.

Hey ginerjm, it’s okay, let me see if I can explain better…

In the sendmail.php file, this bit of code:

	if (isset($_REQUEST['contactemail'])){ $mailTo = $_REQUEST['contactemail']; }
	if (isset($_REQUEST['name'])){ $mailFromName = $_REQUEST['name']; }
	if (isset($_REQUEST['email'])){ $mailFromEmail = $_REQUEST['email']; }
	if (isset($_REQUEST['pickup-addr'])){ $website = $_REQUEST['pickup-addr']; }
	if (isset($_REQUEST['date'])){ $website = $_REQUEST['date']; }
	if (isset($_REQUEST['subject'])){ $subject = $_REQUEST['subject']; }
	if (isset($_REQUEST['message'])){ $message = $_REQUEST['message']; }
	if (isset($_REQUEST['mywebsite'])){ $mailFromWebsite = $_REQUEST['mywebsite']; }

corresponds to the output (the email that is sent when the form is filled out)…

This message was send from:

by: Janessa Mc Kell

Email: janessa.mckell@gmail.com

Pickup Details:

Subject: airport run

Text of message: 1 person with 4 pcs luggage


You’d notice that ‘Pickup Details’ is blank but I have tried assigning that field’s id (pickup-addr) to be displayed after the words ‘Pickup Details’…but it’s not responding that way…The code that is controlling the Display (when the form is emailed):

$msg = "This message was sent from: $mailFromWebsite \
\
by: $mailFromName \
\
Email: $mailFromEmail \
\
Pickup Details: $website \
\
Subject: $subject \
\
Text of message: $message";
	$headers = "MIME-Version: 1.0\\r\
 Content-type: text/html; charset=utf-8\\r\
 From: $mailFromEmail\\r\
 Reply-To: $mailFromEmail";

It’s just leaving it out altogether, even when I change ‘website’ as the field id to ‘pickup-addr’ - see these two lines:

	if (isset($_REQUEST['pickup-addr'])){ $website = $_REQUEST['pickup-addr']; }
	if (isset($_REQUEST['date'])){ $website = $_REQUEST['date']; }

I really hope this explanation is better…

See where you are storing the date input.

What’s that ginerjm?

Look at your code! Where are you storing the date value from your post array?

This message was send from:

by: Janessa Mc Kell

Email: janessa.mckell@gmail.com

Pickup Details:

Subject: airport run

Text of message: 1 person with 4 pcs luggage


You’d notice that ‘Pickup Details’ is blank but I have tried assigning that field’s id (pickup-addr) to be displayed after the words ‘Pickup Details’…but it’s not responding that way…The code that is controlling the Display (when the form is emailed):

$msg = "This message was sent from: $mailFromWebsite \
\
by: $mailFromName \
\
Email: $mailFromEmail \
\
Pickup Details: $website \
\
Subject: $subject \
\
Text of message: $message";
	$headers = "MIME-Version: 1.0\\r\
 Content-type: text/html; charset=utf-8\\r\
 From: $mailFromEmail\\r\
 Reply-To: $mailFromEmail";

It’s just leaving it out altogether, even when I change ‘website’ as the field id to ‘pickup-addr’ - see these two lines:

	if (isset($_REQUEST['pickup-addr'])){ $website = $_REQUEST['pickup-addr']; }
	if (isset($_REQUEST['date'])){ $website = $_REQUEST['date']; }

Your supposed “output” display was NOT generated by the code you have provided. Makes me wonder what code you are running.
Also - what is this “field id” you are referring to? Also - you apparently are NOT entering any data into the ‘date’ field since your pickup addr should be showing a date value since that is where you are stashing the date value. Huge typo.

$website is being assigned the value of ‘pickup-addr’, but then in the next line it’s being assigned to ‘date’, which is a mistake. If you don’t need to collect the date (and you aren’t sending it to the email anyway) then just delete the date input and also this line:

if (isset($_REQUEST['date'])){ $website = $_REQUEST['date']; }

But either way, don’t use $website twice. Change it to something meaningful, like so:

if (isset($_REQUEST['pickup-addr'])){ [COLOR="#FF0000"]$address[/COLOR] = $_REQUEST['pickup-addr']; }
if (isset($_REQUEST['date'])){ [COLOR="#FF0000"]$pickupdate[/COLOR] = $_REQUEST['date']; }

Then output these to email something like this:

$msg = "This message was sent from: $mailFromWebsite \
\
by: $mailFromName \
\
Email: $mailFromEmail \
\
[COLOR="#FF0000"]Pickup Details: $address[/COLOR] \
\
 [COLOR="#0000FF"]Date: $pickupdate[/COLOR] \
\
Subject: $subject \
\
Text of message: $message";

Hey guys…

ralph.m, I’d tried that…There is still no output next to ‘Pickup Details’ and ‘Date’…tsk, a little old form giving so much trouble…

The form code in contacts.html is now:

    <div class="box-form">
      <h2>Contact Form</h2>
      <div class="box error_box" style="display:none;">
        <p> Your message has not been sent successfully. There was an error on the page! </p>
      </div>
      <div class="box info_box" style="display:none;">
        <p> Thank you! Your message has been sent successfully. </p>
      </div>
      <form action="#" method="post" id="contactform">
        <fieldset>
          <div class="box-left1">
            <input type="text" name="name" id="name" placeholder="Your Name (required)" />
            <input type="text" name="email" id="email" placeholder="Your E-mail (required)" />
            <p><strong>Do you need to book us? Please give details. <br />(NB: 50% downpayment required on all drops)</strong></p>
            <input type="text" name="address" id="address" placeholder="Pickup Address" />
            <input type="text" name="pickupdate" id="pickupdate" placeholder="Enter Date and Time of Pickup" />
          </div>
          <div class="box-right1">
            <input type="text" name="subject" id="subject" placeholder="Subject" />
            <textarea name="message" id="message" placeholder="Send more details if you're booking us or if not, you may also send a messsage here."></textarea>
            <input id="formsend" type="submit" value="send" />
            <input type="reset" value="Clear" />
          </div>
          <div class="clear"></div>
        </fieldset>
        <fieldset>
          <div>
            <input type="hidden" value="janessa.mckell@gmail.com" id="contactemail" name="contactemail"  />
          </div>
          <div>
            <input type="hidden" value="php/sendmail.php" id="contacturl" name="contacturl"  />
          </div>
          <div class="loading"></div>
        </fieldset>
      </form>
    </div>
    <!--/ contform--> 

and the code in sendmail.php is now:

<?php
if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'form'){
	if (isset($_REQUEST['contactemail'])){ $mailTo = $_REQUEST['contactemail']; }
	if (isset($_REQUEST['name'])){ $mailFromName = $_REQUEST['name']; }
	if (isset($_REQUEST['email'])){ $mailFromEmail = $_REQUEST['email']; }
	if (isset($_REQUEST['pickup-addr'])){ $address = $_REQUEST['pickup-addr']; } 
	if (isset($_REQUEST['date'])){ $pickupdate = $_REQUEST['date']; }
	if (isset($_REQUEST['subject'])){ $subject = $_REQUEST['subject']; }
	if (isset($_REQUEST['message'])){ $message = $_REQUEST['message']; }
	if (isset($_REQUEST['mywebsite'])){ $mailFromWebsite = $_REQUEST['mywebsite']; }
	
	$msg = "This message was sent from: $mailFromWebsite \
\
by: $mailFromName \
\
Email: $mailFromEmail \
\
Pickup Details: $address \
\
Date: $pickupdate \
\
Subject: $subject \
\
Text of message: $message";
	$headers = "MIME-Version: 1.0\\r\
 Content-type: text/html; charset=utf-8\\r\
 From: $mailFromEmail\\r\
 Reply-To: $mailFromEmail";
	
	mail($mailTo, $subject, $msg, $headers);
}
?>

Still nothing outputting from ‘$address’ and ‘pickupdate’…

ginerjm, I realise there is some funny business going on with this site, as in the changes are being made to the php but then, nothing…It’s a simple micro-site and the sitemap is as such:

getuthere {
about.html
home.html
index.html
services.html
contacts.html
(images - folder)
(css - folder –>
jquery.jscrollpane.css
style.css
nivo-slider.css
prettyPhoto.css)
(js - folder –>
jquery-1.7.min.js
jquery.mousewheel.js
jquery.jscrollpane.js
js/jquery.cycle.all.min.js
jquery.easing.1.3.js
js/jquery.tweet.js
==jquery.prettyPhoto.js"></script>
(php - folder –> sendmail.php)

}

So, in the site itself, I’m not seeing any other php or js file that could be conflicting with what is being output from the form…

You’ve made a major mistake, though. The PHP identifies the input fields by the ‘name’ attribute. (The id is irrelevant to the PHP. That’s really for styling and for associating a label with the input.)

In the HTML you have name=“address” and name=“pickupdate”, but in the PHP you have $_REQUEST[‘pickup-addr’] and $_REQUEST[‘date’]

The PHP would need to be $_REQUEST[‘address’] and $_REQUEST[‘pickupdate’]

Now guys, I don’t want you to think that I’m just this crazy person who has no idea what they’re doing and I’m giving you a bunch of worries here over just my silly mistakes…

The thing is that although that error was there, even when I have all the right values, because I’ve been finagling with this for about two whole weeks before I came on the forum…even when all the right values are there, the form is still not sending ‘Pickup Details’ and ‘Date’, so even in the beginning when I left ‘website’ in the both places, it’s not that I was expecting that code to work but I left it as is to put it up in the forum here to show the complete process of this thing and was explaining that when I switch out $website for the actual fields used in the contacts.html file, the form is still not sending the ‘Pickup Details’ and ‘Date’. And it’s been doing that since like forever…

I really appreciate the assistance, please don’t get frustrated with me or this. Currently the form is still coming to me in the email like this:

This message was sent from:

by: Janessa Mc Kell

Email: janessa.mckell@gmail.com

Pickup Details:

Date:

Subject: Airport Run

Text of message: 4pcs luggage and 1 person

As it is, the code in sendmail.php is as such:

<?php
if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'form'){
	if (isset($_REQUEST['contactemail'])){ $mailTo = $_REQUEST['contactemail']; }
	if (isset($_REQUEST['name'])){ $mailFromName = $_REQUEST['name']; }
	if (isset($_REQUEST['email'])){ $mailFromEmail = $_REQUEST['email']; }
	if (isset($_REQUEST['address'])){ $address = $_REQUEST['address']; } 
	if (isset($_REQUEST['pickupdate'])){ $pickupdate = $_REQUEST['pickupdate']; }
	if (isset($_REQUEST['subject'])){ $subject = $_REQUEST['subject']; }
	if (isset($_REQUEST['message'])){ $message = $_REQUEST['message']; }
	if (isset($_REQUEST['mywebsite'])){ $mailFromWebsite = $_REQUEST['mywebsite']; }
	
	$msg = "This message was sent from: $mailFromWebsite \
\
by: $mailFromName \
\
Email: $mailFromEmail \
\
Pickup Details: $address \
\
Date: $pickupdate \
\
Subject: $subject \
\
Text of message: $message";
	$headers = "MIME-Version: 1.0\\r\
 Content-type: text/html; charset=utf-8\\r\
 From: $mailFromEmail\\r\
 Reply-To: $mailFromEmail";
	
	mail($mailTo, $subject, $msg, $headers);
}
?>

…and the form code in contacts.html is now:

<div class="box-form">
      <h2>Contact Form</h2>
      <div class="box error_box" style="display:none;">
        <p> Your message has not been sent successfully. There was an error on the page! </p>
      </div>
      <div class="box info_box" style="display:none;">
        <p> Thank you! Your message has been sent successfully. </p>
      </div>
      <form action="#" method="post" id="contactform">
        <fieldset>
          <div class="box-left1">
            <input type="text" name="name" id="name" placeholder="Your Name (required)" />
            <input type="text" name="email" id="email" placeholder="Your E-mail (required)" />
            <p><strong>Do you need to book us? Please give details. <br />(NB: 50% downpayment required on all drops)</strong></p>
            <input type="text" name="address" id="address" placeholder="Pickup Address" />
            <input type="text" name="pickupdate" id="pickupdate" placeholder="Enter Date and Time of Pickup" />
          </div>
          <div class="box-right1">
            <input type="text" name="subject" id="subject" placeholder="Subject" />
            <textarea name="message" id="message" placeholder="Send more details if you're booking us or if not, you may also send a messsage here."></textarea>
            <input id="formsend" type="submit" value="send" />
            <input type="reset" value="Clear" />
          </div>
          <div class="clear"></div>
        </fieldset>
        <fieldset>
          <div>
            <input type="hidden" value="janessa.mckell@gmail.com" id="contactemail" name="contactemail"  />
          </div>
          <div>
            <input type="hidden" value="php/sendmail.php" id="contacturl" name="contacturl"  />
          </div>
          <div class="loading"></div>
        </fieldset>
      </form>
    </div>
    <!--/ contform--> 

Now this is a micro-site that I’m just customising, so what it was out of the box was this:

sendmail.php

<?php
if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'form'){
	if (isset($_REQUEST['contactemail'])){ $mailTo = $_REQUEST['contactemail']; }
	if (isset($_REQUEST['name'])){ $mailFromName = $_REQUEST['name']; }
	if (isset($_REQUEST['email'])){ $mailFromEmail = $_REQUEST['email']; }
	if (isset($_REQUEST['website'])){ $website = $_REQUEST['website']; } else { $website = 'unknown'; }
	if (isset($_REQUEST['subject'])){ $subject = $_REQUEST['subject']; }
	if (isset($_REQUEST['message'])){ $message = $_REQUEST['message']; }
	if (isset($_REQUEST['mywebsite'])){ $mailFromWebsite = $_REQUEST['mywebsite']; }
	
	$msg = "This message was send from: $mailFromWebsite \
\
by: $mailFromName \
\
Email: $mailFromEmail \
\
Website: $website \
\
Subject: $subject \
\
Text of message: $message";
	$headers = "MIME-Version: 1.0\\r\
 Content-type: text/html; charset=utf-8\\r\
 From: $mailFromEmail\\r\
 Reply-To: $mailFromEmail";
	
	mail($mailTo, $subject, $msg, $headers);
}
?>

…and the form code in contacts.html:

<div class="box-form">
      <h2>Contact Form</h2>
      <div class="box error_box" style="display:none;">
        <p> Your message has not been sent successfully. It was an error on page! </p>
      </div>
      <div class="box info_box" style="display:none;">
        <p> Thank you! Your message has been sent successfully. </p>
      </div>
      <form action="#" method="post" id="contactform">
        <fieldset>
          <div class="box-left1">
            <input type="text" name="name" id="name" placeholder="Your Name (required)" />
            <input type="text" name="email" id="email" placeholder="Your E-mail (required)" />
            <input type="text" name="url" id="url" placeholder="Your Website:" />
            <input type="text" name="subject" id="subject" placeholder="Subject" />
          </div>
          <div class="box-right1">
            <textarea name="message" id="message" placeholder="Message"></textarea>
            <input id="formsend" type="submit" value="send" />
            <input type="reset" value="Clear" />
          </div>
          <div class="clear"></div>
        </fieldset>
        <fieldset>
          <div>
            <input type="hidden" value="your@mail.com" id="contactemail" name="contactemail"  />
          </div>
          <div>
            <input type="hidden" value="php/sendmail.php" id="contacturl" name="contacturl"  />
          </div>
          <div class="loading"></div>
        </fieldset>
      </form>
    </div>
    <!--/ contform-->

…so what we’ve been discussing is my edited bit of code…I’m putting the previous code so that perhaps it may clue us in as to why the edited code is not working…?! :-/

Hopeful…

Presumably that original code didn’t work either? Because it has $_REQUEST['[COLOR="#FF0000"]website[/COLOR]'] in the PHP while, in the HTML, it says name="[COLOR="#FF0000"]url[/COLOR]", which doesn’t match.

Did I miss something here?

I don’t like this code either. You are NOT showing us what you are executing.

Reason: Your first line of php looks for an input named ‘type’. This field is not defined in your html code. Period. I could almost think you were trying to determine the "type of request’ but I give up on that idea when you test for a value of ‘form’. What is that?

Anyway, the failure to get a true response for that above line causes you NOT to obtain any of the values you seem to be getting. So - the output you are showing us as your supposed result is being manufactured by you OR BEING GENERATED BY SOME OTHER CHUNK OF CODE.

I get really frustrated by posters who give us one thing while doing something else and then ask us to not get that way. Sheesh!

Hey ralph.m, I’m going to try the site in it’s original form and see if the form works…

Hmm, actually, the original code isn’t working - I inserted my email address in this line (see below- somewhere around line 54) of the original, uploaded it to my server and nothing:

<input type="hidden" value="janessa.mckell@gmail.com" id="contactemail" name="contactemail"  />

You can see the original site here:
http://wellgetuthere.com/getuthere-test/

and this is my edited site:
http://wellgetuthere.com/getuthere/

Hey ginerjm, there isn’t anything else in the site that’s running…this is all the form code here that I’ve sent…

I sent the sitemap - it’s a small micro-site:

getuthere {
about.html
home.html
index.html
services.html
contacts.html
(images - folder)
(css - folder –>
jquery.jscrollpane.css
style.css
nivo-slider.css
prettyPhoto.css)
(js - folder –>
jquery-1.7.min.js
jquery.mousewheel.js
jquery.jscrollpane.js
js/jquery.cycle.all.min.js
jquery.easing.1.3.js
js/jquery.tweet.js
==jquery.prettyPhoto.js"></script>
(php - folder –> sendmail.php)

}

I don’t buy it. You’re not giving us the whole picture. Your html code is being included in some other script (you’re not showing us) and the points I made have to be explained by that other script. Do some research on this stuff and come up with an answer.

I am NOT going to dig into all your other pieces of code. Authors do that.

Good luck.

No problem ginerjm

I think at this point I’d recommend you dump this form script you are using and try another one, as there is something too weird going on. But before that, I have a stronger recommendation. All of the content on your site is served up by JavaScript, which is totally unnecessary, and a very bad idea. With JS off, there’s no content on your site. That may not bother you, but there are other consequences to this, such as there being no content on your site for Google to index. So really, I would advise you to start from scratch here—build the site with HTML and CSS (no JS) and then use a nice, clean form script that is straightforward and secure. :slight_smile:

Okay, :slight_smile: thanks very much Ralph…