Contact Form Web Application Tutorial Ajax HTML5 PHP

Поделиться
HTML-код
  • Опубликовано: 16 авг 2024
  • In this exercise we will demonstrate how to build a modern all-purpose website contact form that uses new HTML5 features, Ajax and PHP. Everything happens without reloading the page or navigating to another document to parse the data. You can put this form to work on any website that processes PHP, and you can modify it for other purposes.

Комментарии • 267

  • @Timespider
    @Timespider 8 лет назад +3

    Fantastic as usual. Followed you for years down here in NZ. Your videos are like unwrapping a present at Christmas, can't wait to see what goodies are inside.

  • @user-hk3te3ql5p
    @user-hk3te3ql5p 8 лет назад +2

    many thanks.
    i wait notification about :
    MVC tutorials BY Adam Khoury
    :)

  • @enriquebdfx
    @enriquebdfx 8 лет назад +1

    Thanks for investing your time in this vids men, regards from Venezuela!

  • @stephenbradbury2347
    @stephenbradbury2347 6 лет назад +1

    I know this tutorial is over 2 years old now but I have just used it on my website, it works as it should.
    Thank you very much.
    Subscribed.

  • @richardrichardson5745
    @richardrichardson5745 8 лет назад

    Thanks for this tutorial.
    This looks like it will be more convenient than sending the viewer to a separate page.
    I will be doing this for my future websites.

  • @lojose1000
    @lojose1000 8 лет назад +1

    very nice tutorial, and thanks for share, nice to have u back

  • @GeorgeLathem
    @GeorgeLathem 7 лет назад +4

    Finally a simple and to the point tutorial. I fucking love you! Liked and Subscribed

  • @MRMOTOFOTO
    @MRMOTOFOTO 8 лет назад +2

    I can't thank you enough.....I've learned more from you than Anything out there.

    • @AdamKhoury
      @AdamKhoury  8 лет назад

      Glad you find it useful. Thanks for the feedback.

  • @ChimobiHD
    @ChimobiHD 8 лет назад +3

    The dude is back! Thanks for all the good work Adam

  • @BOER1717
    @BOER1717 8 лет назад +1

    Yay, you're back!!!! Awesome as always Adam, keep up the good work ✌🏻️

    • @AdamKhoury
      @AdamKhoury  8 лет назад +2

      Thank you sir. It's good to be back in action.

  • @madpeach_
    @madpeach_ 5 лет назад

    Thanks a lot. Was scared of dealing with backend languages but thanks to you now i see a whole new world of possibilities!

  • @emanuelolsson7169
    @emanuelolsson7169 7 лет назад

    Thank you, really nice. As for Wordpress users or others that experience the "Please wait..."-issue - it is because your parser.php cannot be found. If you are using wordpress you'll need to include it in for example your functions.php. I found this out using the inspector, use to see where the errors occur and why.

  • @joannasmith2133
    @joannasmith2133 5 лет назад

    Brilliant tutorial! I'm a beginner coder and your tutorials are such a huge help: informative, clear and to the point. Thank you!

  • @gtaagent
    @gtaagent 7 лет назад

    Well done. Very simple and explained perfectly. It's important to note for people having problems it's paramount that the .php file be referenced exactly the same in your javascript because once the user submits the form the target is that file, the rest is effortless.

  • @minakirellos9089
    @minakirellos9089 8 лет назад +1

    Keep it up man! I have learned a lot from your tutorials
    Thanks

  • @kamaboko1
    @kamaboko1 8 лет назад +1

    Nice to see you back

  • @labradorconnect25
    @labradorconnect25 8 лет назад +1

    You are an UNBELIEVABLE teacher! Thank you for this video!
    I am curious how I take this and "connect" it to my Google or Mailgun SMTP?

  • @Timespider
    @Timespider 4 года назад

    I needed a refresh.
    Been missing your tutorials and humor AK, can't wait till your back.
    Your the best teacher!

  • @AdamKhoury
    @AdamKhoury  8 лет назад +1

    Research the terms Cross-site Scripting (XSS) and Cross-Site Request Forgeries (CSRF) attacks in a search engine to find numerous methods to defend your forms against spam and automated attacks from malicious third party servers.

  • @vonstormfilms
    @vonstormfilms 8 лет назад +1

    Love your content, Adam. Thanks a ton.

  • @hugoalvarez3226
    @hugoalvarez3226 6 лет назад

    Thanks for the example and mostly for the code, I was really spinning around with the serialize of php which didn't worked for me in hours. Just downloaded and customized your code and its all working fine. Thanks!

  • @4loverhyme
    @4loverhyme 5 лет назад +1

    ... it's working for me, great job, and thanks for saving me lots of time in having to write the code, thanks again!

  • @NoahNobody
    @NoahNobody 8 лет назад +1

    Hi Adam, I was browsing your site and noticed there wasn't any content about web security. I would like to express my interest in this field and request some practical tutorials about it. For example, XSS, XSRF, and anything using Ajax that might compromise a database.
    Thanks.

  • @math487
    @math487 8 лет назад +1

    great video once again thank you very much

  • @bongloads420thc
    @bongloads420thc 7 лет назад

    The best tutorial I've seen on this topic. Subscribed.

  • @felixmoshami17
    @felixmoshami17 7 лет назад +2

    you have great tutorial man i just like your tuts thank you for sharing your knowledge

  • @martincool7333
    @martincool7333 7 лет назад

    Hi Adam the problem is you make it look so simple. Thanks for the tutorial

  • @nicknoop
    @nicknoop 6 лет назад

    Thanks Adam, much appreciated!
    If anyone else interested in adding a honeypot to this, here below are some slight additions/amendments made. This worked for me in terms of the form not sending. I have been scratching my head to add a 'false' success message, but failed so far...!
    In form, add this line:
    If you're human, leave this empty:
    In script, add this:
    formdata.append( "hon-url", _("hon-url").value );
    In css, hide the line in the form:
    .antispam {display: none;}
    In php, add this:
    if( isset($_POST['n']) && isset($_POST['e']) && isset($_POST['m']) && isset($_POST['hon-url']) && $_POST['hon-url'] == ' ' ) {....here goes the rest.....}

  • @kevinwiens4804
    @kevinwiens4804 7 лет назад +1

    Sweet.....Adam!!

  • @kishandave722
    @kishandave722 8 лет назад +1

    very nice video Thanks bro

  • @floris812
    @floris812 7 лет назад +2

    Wow you're a good teacher!

  • @CarliBotes
    @CarliBotes 8 лет назад +1

    Love your tutorials! Thank you :D

  • @tiagomartinho77
    @tiagomartinho77 5 лет назад

    thank you, it was very helpful, already up and running, i only added a subject placeholder. Only problem i have to sort is the language, in portuguese we have "ç" and "ã" and come all wrong. Great job, keep it coming and thank you for sharing

  • @royalkinguniverse
    @royalkinguniverse 6 лет назад +3

    im so dissapointed i did everything u said and it does not work??? uploaded it to the server it says thanx for sending an email but it doesnt send an email?

  • @BreakthroughGolf
    @BreakthroughGolf 8 лет назад

    Thank you so much! Everything worked great, except the "please wait" message and nothing is arriving in email.

  • @kevinwiens4804
    @kevinwiens4804 7 лет назад

    This is Really Good Stuff Adam..

  • @AlisTDK
    @AlisTDK 8 лет назад

    saludos amigo! gracias por tus tutoriales, me ayudan mucho! thanks for your help friend!

  • @IrfaanHassanDiamonds45
    @IrfaanHassanDiamonds45 7 лет назад

    Hi Mr Adam Khoury.. and how you doin mahn??!?
    I had to pause the video!! fucking love your work!! love how real you are about coding and programming, ive been watching your vids and you make me feel like ive been programming for years already.. you know when to elaborate what is a built in function of php and what is not built in, love that, doesnt leave me guessing what needs to be instantiated or not.. Keep up the awesome work! and May The Almighty bless you and those you love and care for in this world and the world after.aameen.

  • @Dexter101x
    @Dexter101x 7 лет назад

    My php script is a little bit more complicated than yours Adam, but I always couldn't do the response message when people have sent the message and also, the HTML email. Thanks

  • @ravgeetdhillon2990
    @ravgeetdhillon2990 5 лет назад +2

    That's exactly what I was looking for.

    • @vincentthiago9526
      @vincentthiago9526 3 года назад

      I guess it's kinda randomly asking but do anyone know a good site to stream newly released movies online ?

    • @piercejonah6289
      @piercejonah6289 3 года назад

      @Vincent Thiago Try flixzone. Just google for it :)

    • @kamdenstanley1449
      @kamdenstanley1449 3 года назад

      @Vincent Thiago I use flixzone. You can find it by googling :)

  • @cyrusbfbulan6573
    @cyrusbfbulan6573 5 лет назад +2

    sir Adam I've only confirming that the message was sent but their is no message at my inbox(the recipient) ..please help

  • @WOXZE
    @WOXZE 8 лет назад

    Thank you very much sir. That was awesome!

  • @moehammoud1
    @moehammoud1 6 лет назад

    Great tutorial. Exactly what I wanted/needed. Thanks, mate. Keep up the good work.

  • @LarsVollaers
    @LarsVollaers 8 лет назад +1

    Thanks alot, I was looking for this!

    • @AdamKhoury
      @AdamKhoury  8 лет назад

      Thanks for the feedback Lars.

    • @LarsVollaers
      @LarsVollaers 8 лет назад

      I was wondering if you could make a lesson that inserts data to the database with ajax of course. Let's say for example a comment system.

    • @BOER1717
      @BOER1717 8 лет назад +1

      Check out his "Social Media' series, he has all that in there with AJAx

  • @miguiaculiacan
    @miguiaculiacan 8 лет назад +1

    thanks Adam !

  • @Vexxlol
    @Vexxlol 7 лет назад +3

    Not working, It just says Please Wait...... And never sends and i have a domain email

    • @Vexxlol
      @Vexxlol 7 лет назад +1

      Righty'o Ill go check it out

  • @yakut54
    @yakut54 7 лет назад

    ёмко и содержательно. спасибо, чувак! =)

  • @jamiebrunson7584
    @jamiebrunson7584 7 лет назад +2

    Great tutorial, however, I am having a bit of an issue. When I upload and run the contact script, the form stays on the page, the page will refresh and send me back to the top and it appends all the data I entered to the end of the domain name in the address bar above. Any thoughts sir?
    Just to update, im getting this Error now:
    [19-Nov-2016 15:55:39] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/php/54/usr/lib64/php/modules/imagick.so' - /usr/php/54/usr/lib64/php/modules/imagick.so: undefined symbol: zend_new_interned_string in Unknown on line 0

  • @alaadinshexahmedbarznji7911
    @alaadinshexahmedbarznji7911 8 лет назад

    very good well done

  • @matthijs162
    @matthijs162 8 лет назад +1

    Hey Adam, This form works perfectly, except for the receiving part. Whenever I sumbit,
    the email is sended to my spam folder, how can i let it go into the regular inbox folder?
    Kind regards

    • @AdamKhoury
      @AdamKhoury  8 лет назад

      Maybe because your email checking application's spam filtering settings are high and you only allow trusted white-listed entities land in the inbox. You could try changing the $from variable to use an email address tied to your hosting account that is sending the email, instead of the user's $e variable. I am not sure really.

  • @stephanstanisic2007
    @stephanstanisic2007 8 лет назад

    You should have added a else in the isset of the parser, to tell the user that ons of the fields is empty if they are using a browser that does not understand the required inputs (like iOS' safari). But nice script!

  • @ClawHammer23
    @ClawHammer23 8 лет назад

    Thanks for share Adam

  • @escapecs9498
    @escapecs9498 5 лет назад +2

    Mine just says please wait... and it stops there it does not redirect me to " your message has been sent" any tips?

  • @radhakrishnankp8592
    @radhakrishnankp8592 8 лет назад +1

    Nice...

  • @yndev
    @yndev 7 лет назад

    Still works in 2017. Thanks for this!

    • @yndev
      @yndev 7 лет назад

      Nah, I followed the video exactly and it worked. The issue could be your with your host possibly?

    • @makemoneyrelax
      @makemoneyrelax 7 лет назад

      yes it works on mine.....you need to use it on real server....maybe on local host it will not work for some reason....which is understandable....

  • @lisawoodson9511
    @lisawoodson9511 7 лет назад +2

    Do you know how to configure XAMPP so that I don't get this error? ...
    Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\1ContactFormWebApplicationAjaxHtml5Php\example_parser.php on line 13
    The server failed to send the message. Please try again later.

  • @Trident007
    @Trident007 8 лет назад

    great video thank you! is there a video out there the shows how to add spam filters to one of these contact forms?

  • @GracieDFC
    @GracieDFC 7 лет назад +1

    Hi Adam, my email is not sending and form says please wait but nothing happens. any ideas? thanks.

  • @realist8774
    @realist8774 8 лет назад

    Great tutorial! Could you make a sequel to this one teaching folks how to protect this wonderful form from spam (like recaptcha)?

  • @ShapeoneCoIl
    @ShapeoneCoIl 6 лет назад

    Just what i was looking for - thank you so much

  • @yutu49
    @yutu49 7 лет назад +1

    Doesn't work. I copied your html, JavaScript, and php code exactly form your developphp page and put the codes in their respective pages. The php page was named exactly as yours.
    I entered the information into he fields properly and hit submit. all that happened was that the php code was displayed directly under the form.

    • @General_Aladeen
      @General_Aladeen 7 лет назад +1

      learn how to debug man. look in the developer console if you've javascript errors.

  • @houssameddine6105
    @houssameddine6105 8 лет назад

    great video... i have a question : why did you use iso as an unicode why did you not use utf-8

  • @sohampatel6916
    @sohampatel6916 6 лет назад

    that was very easy. and you did good putting your code for us to copy. great

    • @nksprashant
      @nksprashant 6 лет назад

      www.developphp.com/video/JavaScript/Contact-Form-Web-Application-Tutorial-Ajax-HTML5-PHP

  • @neukekeuke9287
    @neukekeuke9287 8 лет назад

    Man it works perfect! THX a lot

  • @julianvarga
    @julianvarga 8 лет назад

    Thank you for this simple tutorial. I've been trying to do this for almost a year and I was finally able to do it because of you. I'm a fan now. Question, is this form safe from hackers? I've seen other tutorials in which they add a "human" component in which they have to answer a simple question in order for the form to be accepted. If not, is this hard to do?

  • @Peternakkece
    @Peternakkece 8 лет назад

    thankyou for the tutorial sir

  • @janoytechwizz3874
    @janoytechwizz3874 5 лет назад

    Thank you, i may now optimize my website.

  • @souviknag
    @souviknag 8 лет назад +1

    Firstly, your videos are very helpful. Thank you very much. Could you please tell, if we can call multiple jquery/javascript functions onsubmit event?

    • @AdamKhoury
      @AdamKhoury  8 лет назад +2

      OR
      Maybe you can execute those other functions from inside of the submitForm() function.

    • @projectstarhubcitylive4473
      @projectstarhubcitylive4473 8 лет назад

      osm .. you are great .but how you learn this hard Java Script ?

    • @souviknag
      @souviknag 8 лет назад

      Thanks for the reply. I was watching your videos relating OOP lately. I was wondering if you could please make a series of basic OOP related videos. Or if I have missed them, would you please tell me where to find them? Once again, thank you very much for the tutorials. They're very helpful.

  • @murtuzaali
    @murtuzaali 7 лет назад

    i love u boss thank you sir u help me a lot thanksss

  • @muhammadshahryarazhar2571
    @muhammadshahryarazhar2571 5 лет назад

    Great!!!
    Thanks for the video man!
    Really appreciate it!!!

  • @jamesbarratt593
    @jamesbarratt593 6 лет назад

    Need form submitted message on screen of form which is whole reason for using ajax. I have a form using jquery validate, and jquery holds submit button until validation passes. Then with submit free it posts to php and php opens new window to display sent message. I want to have this message on the same page as the form.

  • @Oscar-mp6hw
    @Oscar-mp6hw 8 лет назад

    I quadrupled check my code and its identical to yours except for the form fields and it is not working. For some weird reason it is acting as it's method is "GET" (showing the information on the browsers address bar). I made sure it was "POST" but nothing.
    Do you have any idea what could be wrong?

  • @ak-loz
    @ak-loz 6 лет назад

    This works wonderfully!

  • @peterscott9520
    @peterscott9520 2 года назад

    Hi Adam, Thanks for your excellent tutorial, which I used to create a nice contact form. I have a question: Would it be possible to use PHP's output buffer with a callback function to collect form data instead of using AJAX? Thanks in advance for any thoughts...
    -- Peter

  • @thehangman1517
    @thehangman1517 2 года назад +1

    Hello, how does this send the email?
    How does this work, can you explain this?

  • @pigpen12345
    @pigpen12345 7 лет назад

    Browser discrepancies
    Okay, I get the success message in safari "thanks (name) your message has been sent", but in chrome or firefox, I just stays on "please wait". I do get the email on all browsers though.
    How do I fix this?

  • @brovayurbee
    @brovayurbee 7 лет назад

    I have a few radio buttons and phone number section added in code. If I wanted to display the number I would have to add in my php section.

  • @sabiruli
    @sabiruli 6 лет назад

    Thanks a lot for valuable tutorial.

  • @kayodelawal7703
    @kayodelawal7703 7 лет назад

    Hey there Adam thanks for this tutorial but, when i upload the form to my site, and fill it out the page just refreshes. and no email set out

  • @kyleparsotan6799
    @kyleparsotan6799 4 года назад +1

    Do we need a sql and php to get the data saved and see who is what?

  • @aswanigupta
    @aswanigupta 6 лет назад

    Thank you so much for this video. I visited your website where i have seen some social icons on the left side of your page . if Possible then please make a video for making that

  • @sukronjazuli
    @sukronjazuli 5 лет назад +1

    my message no show in email, only information has been sent.... , why sir... please help ..thank so much

  • @atypical_blk_guy
    @atypical_blk_guy 8 лет назад

    Hey I'm getting an error message in the console saying submitForm is not defined even though I got the same code to work for another website I'm working on. Any ideas why it would work for one site but not the other? I also tried copying and pasting the sample code and I still get the same message.

  • @sksarifulislam2753
    @sksarifulislam2753 7 лет назад

    Hello Sir
    I am beginner of website design and developing process through youtube specially ur all content even HTML video control. I was completed all design with HTML&CSS&JS, as well as login and sing up page with PHP& Mysql database as u providing to video. But could find out how to connect both PHP script and index.html main file together in hostgator hosting service mysql database.
    Thank You

  • @kppavu8809
    @kppavu8809 6 лет назад +1

    awesome man thank you so much

  • @makemoneyrelax
    @makemoneyrelax 7 лет назад

    dude, I LOVE YOU!!!!! YOUr form works on my site beautifully......maybe you can add subject too to the form? I mean when you get the email the subject should be in the title of the email {from}

  • @masreshayayeh1082
    @masreshayayeh1082 8 лет назад +1

    I JUST TRY BUT I GOT :- Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\CONTACT_FORM\example_parser.php on line 34
    The server failed to send the message. Please try again later.

  • @andrewvalenzuela1790
    @andrewvalenzuela1790 6 лет назад

    Thank you, that was really helpful

  • @billbyrd9845
    @billbyrd9845 4 года назад

    It was working fine for me. Thank you for that. But then... it quit working and stalls with "Please wait..." Any ideas?

  • @TGDTom
    @TGDTom 6 лет назад

    When I try to include the security.php file, I get a HTML 500 error, and if I don't include it, submitting the form (if everything is filled in) doesn't work. Any ideas?

  • @Xaidinatorx2000X
    @Xaidinatorx2000X 8 лет назад

    Can you make a video on how to make a website where you can make a admin account where you can upload, title and add a description and allow people to make user accounts to comment and like ? If so that would be awesome

  • @andrewrico8321
    @andrewrico8321 6 лет назад +2

    not working.....it says "please wait" after submit it and then nothing happend.

    • @yoyoking132
      @yoyoking132 6 лет назад

      me too, did you end up getting it to work?

    • @andrewrico8321
      @andrewrico8321 6 лет назад

      i didnt, try:
      formspree.io/

    • @M9Diry
      @M9Diry 6 лет назад

      Me too then I checked the and found that because I changed the name example_parser.php to something but hadn't changed the reference in the script. Bang.

  • @NikhilPatil647
    @NikhilPatil647 6 лет назад

    Thank you very much for Code :

  • @rajeshsahu605
    @rajeshsahu605 7 лет назад

    sir i know only html and css can i go for this tutorial?????
    plase uploaded the html5 and css3 tutorial so that its very easy to getting php and javascript

  • @raxa138
    @raxa138 6 лет назад

    Works perfect! Thanks!

    • @sukronjazuli
      @sukronjazuli 5 лет назад

      are you just copy code in website link www.developphp.com/video/JavaScript/Contact-Form-Web-Application-Tutorial-Ajax-HTML5-PHP why for my not work... please help thank you

  • @RS-hw8cz
    @RS-hw8cz 7 лет назад +1

    it say mail sent .but i do not receive any mail from this .i just changed the email address in php file and then i upload it on my domain .what else should i do .plz help

  • @jsphpndr
    @jsphpndr 7 лет назад

    This was a great tutorial. I have yet to really follow up with PHP, but this was simple enough. I'll use your site references to work on the security. Other than that, everything works great. Could this work with PHPMailer?

  • @riza8617
    @riza8617 6 лет назад

    so I use javascript to process data then send data that has been inputted via ajax to php and php processes data from javascript to send email?

  • @adam6039
    @adam6039 8 лет назад

    When you finish the form, and when you enter the information and click Send writes me please wait and so to write and nothing happens , I do not know what to do , please help!
    please helpppppppppppppppppppppppppppppp

  • @Stephen-st1pi
    @Stephen-st1pi 7 лет назад

    Dear Adam,
    I uploaded your files almost as is, on the website. The only change I made was to my email address. After clicking on "Submit", the message thanked my name, but I did not receive the email at all. I have checked my spam mail as well. Please advise, if possible.
    Stephen.