简体   繁体   中英

How Can I Create A Simple PHP Mail Form For My Website?

I already have a form set up on my site. I created the form code myself.

I started experiencing problems with having the information e-mailed to me, one day everything is fine and it gets e-mailed to me, the next day the confirmation message comes up but nothing gets sent to my e-mail.

This is very critical for my line of work.

My question is: How can I create a simple php mail form that will always work?

This is the code I have now:

    $('#rSubmit').click(function(validateform){        
      var data = {};
      data.to = "greatlimoservice@gmail.com";
      data.from = "greatlimoservice@greatlimoservice.com";
      data.subject = "New Reservation"; 
      data.message = "New Reservation from Website \n"+
                        '\n First Name      : '+$('#name').val()+
                        '\n Last Name       : '+$('#lastname').val() +
                        '\n Company Name    : '+$('#company').val() +
                        '\n Phone Number    : '+$('#phone').val() +
                        '\n Street Address  : '+$('#street').val() +
                        '\n Pick-Up City    : '+$('#city').val()+
                        '\n Pick-Up State   : '+$('#state').val() +
                        '\n Pick-Up Zip     : '+$('#zip').val() +
                        '\n Date            : '+$('#calendar').val()+
                        '\n Time            : '+$('#time').val() +
                        '\n Time            : '+$('#time2').val() +
                        '\n Time            : '+$('#time3').val() +
                        '\n Airport         : '+$('#airport').val() +
                        '\n Airline         : '+$('#airline').val() +
                        '\n Flight #        : '+$('#fnumber').val() +
                        '\n Stops           : '+$('#hstops').val() +
                        '\n Stops Info      : '+$('#info').val() +
                        '\n Passengers      : '+$('#passengers').val() +
                        '\n Luggages        : '+$('#luggages').val()+
                        '\n Car Seat        : '+$('#seat').val()+
                        '\n Drop-Off Street : '+$('#dostreet').val() +
                        '\n Drop-Off City   : '+$('#docity').val()+
                        '\n Drop-Off State  : '+$('#dostate').val() +
                        '\n Drop-Off Zip    : '+$('#dozip').val() +
                        '\n D.O Airport     : '+$('#doairport').val() +
                        '\n D.O Airline     : '+$('#doairline').val() +
                        '\n Flight #        : '+$('#dofnumber').val() +
                        '\n Date            : '+$('#calendar2').val()+
                        '\n Time            : '+$('#rtime').val() +
                        '\n Time            : '+$('#rtime2').val() +
                        '\n Time            : '+$('#rtime3').val() +
                        '\n Return Street   : '+$('#rtstreet').val() +
                        '\n Return City     : '+$('#rtcity').val()+
                        '\n Return State    : '+$('#rtstate').val() +
                        '\n Return Zip      : '+$('#rtzip').val() +                            
                        '\n Return Airport  : '+$('#rtairport').val() +
                        '\n Return Airline  : '+$('#rtairline').val() +
                        '\n Return Flight # : '+$('#rtfnumber').val() +                         
                        '\n Payment Type    : '+$('#payment').val() +
                        '\n Card Number     : '+$('#creditcardno').val() +
                        '\n Exp. Date       : '+$('#expirydate').val() +
                        '\n Exp. Date       : '+$('#expirydate2').val()

                    ;

alert("Congratulations! Your reservation has been made. Your confirmation number is 3851. Please contact us if you have any questions or comments.");




});

Is there any other easier/convenient way or coding I can use that will work properly? I need to always get an e-mail once a person clicks "Submit" on my site and this coding isn't working for me

In regards to: "How can I create a simple php mail form that will always work?"

There are many PHP based forms that can be found on the Web, and you will find many by Googling "php form with validation", for example. Make sure that it includes proper validation and sanitization.

Also consult Sanitize filters on PHP.net and here also for examples.

PHP(.net) has a function called mail() which you can read up on. Click here to see it.

Google "ajax email form" and you will get many hits.


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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM