Online RSVP form and database with PHP, JavaScript and MySQL

Requirements

Recently, I needed an online RSVP system for a reception I was hosting, all the options out there didn’t meet my requirements;

  • Customisable and able to self-host
  • No need for tracking codes/numbers to be sent with invitation
  • Able to RSVP additional guests
  • Able to modify an existing RSVP

Implementation

As usual, I decided to implement my own online RSVP solution, which has the following functionality;
  • PHP/JavaScript front-end
  • MySQL back-end
  • Sleek CSS (borrowed from WordPress)
  • Client-side checking with JavaScript
  • Server-side checking with PHP
  • Very basic submission viewing in HTML, wasn’t a real requirement as I could browse the database with phpMyAdmin, but it was good to have some visibility without the need of logging in

Installation

  • You will need PHP installed and a MySQL database.
  • Import the following SQL query to create a RSVP table with required fields.
  • Create a folder on your web hosting.
  • Extract the following zip file contents to this newly created folder.
  • Edit rsvp.php and configure your database settings, including database name, user name, password and host.
  • If using the optional email confirmation, configure the email from address and email body contents.
  • On your website, create an iframe to show the RSVP form.
Testing
  • Navigate to rsvp.php and submit a test response.
  • Navigate to res.php and confirm you can see your test response.
  • Alternatively, view the MySQL table directly (with phpMyAdmin)
Downloads

Demo

Improvements

Two small things I would have added, known after it’s use;

  • Client-side checking for ‘and’ in the full name field, few guests still tried to add themselves and their partner in that field.
  • Improved response email that would be addressed to all guests not just the first name.

Posted

in

,

by

Comments

41 responses to “Online RSVP form and database with PHP, JavaScript and MySQL”

  1. Need free rsvp php script – Software Development

    […] Re: Need free rsvp php script have a look at this example with demo; http://mectile.com/online-rsvp-form-…ipt-and-mysql/ […]

  2. Krodami Avatar
    Krodami

    Awesome, just what i was looking for, thank you

  3. Jimmer Avatar
    Jimmer

    this is great ..wonder if an interface can be added where you can add or delete records

    1. Travis h Avatar

      Jimmer, it easily could, but I did it from phpMyAdmin

  4. Corey Poole Avatar
    Corey Poole

    im a getting many errors such as please help

    Notice: Undefined index: vegetarian1 in C:xampphtdocsrsvprsvp.php on line 230
    Notice: Undefined index: vegetarian0 in C:xampphtdocsrsvprsvp.php on line 230

    1. doncamillo Avatar
      doncamillo

      Add this to the top of the code
      error_reporting( error_reporting() & ~E_NOTICE )

  5. Ben Chester Avatar
    Ben Chester

    Travis, Is there an easy way to add more check boxes to the vegetarian option? i want to have 3 options; veg, chicken, beef. And change from check box to radio?

    1. Travis h Avatar

      Ben, it is easy depending on your PHP and html skills.
      But basically the ‘veg’ database variable, can be changed to generic meal type variable of char (string).
      Have a look at the other radio button options for example code.

  6. durale Avatar
    durale

    great form thanks for sharing your code,well appreciated

    for clean results, you can also replace this query SELECT * FROM `rsvp`; by this one :
    SELECT * FROM `rsvp` where id=(select max(id) from rsvp as i where i.email = rsvp.email)

    so it gives you only one row even if you are getting many rows update for the same email address.

  7. […] We offer cheap, professional and fast Perl script installation service. Read More… […]

  8. Sean Avatar
    Sean

    Hi Travis, How do i make it jump into existing retrieve data rather then the new entry?

    1. Travis h Avatar

      When the user clicks on modify existing, they need to enter their email they initially used and they will get their previous data.
      It doesn’t create a new database record though as I wanted to track the changes.

      1. Sean Avatar
        Sean

        Cool. The thing is that, i have the email, name and etc in a DB that im sending out the invitation. Id just thought, maybe jumping to edit page just to get a confirmation from the user. Which im also thinking of passing the email address to the form via a URL query string, where ill be able to dynamically insert the persons email address from the email that im sending out. Any thoughts?

        1. Travis h Avatar

          Yeh, anything is possible. Are you sending the invitations via email, if so you can make each link to the RSVP form individual and directs to a pre-filled in page.
          If you just want to allow them to confirm an existing record, make the modification option default.

          1. Sean Avatar
            Sean

            That sounds pretty much right, how do i make the modification option default? ps: Im learning PHP while i work on this…. 🙂 Need it for my sisters wedding soon.

  9. Mark Chauvin Avatar
    Mark Chauvin

    How do I remove the vegetarian options completely? (we cant afford it for the event). I am fairly good ad modding, just need to know what I am looking for.

    Thanks

  10. Shaun Middlebusher Avatar
    Shaun Middlebusher

    Deprecated: Function split() is deprecated in…rsvp.php on line 41
    any way to fix this?

  11. Nika Gerson Lohman Avatar
    Nika Gerson Lohman

    Great stuff! Judging from the warnings you should be using isset before checking variables that may not be set yet (like $included or the database variables)…

  12. Evan Avatar
    Evan

    I am completely lost on how to put this page up. Problem I’m having is the rsvp.php that you show here as a demo works fine (the code doesn’t contain any php from the looks of it). The php in the zip file though does not. The main problem is that after the first echo function, all of the php code shows up on the page. This only happens after this point. Am I missing something?

  13. fireflyimageworks Avatar
    fireflyimageworks

    Travis! First off, an amazingly helpful bit of code, my friend. Thank you.
    That said, I’m wanting the “Modify Existing” option to actually update the table entry it’s retrieving as opposed to creating an entirely new, duplicate entry.
    I’ve been messing around with ON DUPLICATE KEY UPDATE within the PHP, but so far, can’t seem to get it to take. It’s your code. Maybe you have a better suggestion? Worth an ask. Thanks in advance!

    1. Travis h Avatar

      Hi fireflyimagework

      Yes, I designed it to only add new entries as I didn’t want the risk of wrongly deleted items.

      To actually modify the entry try something similar to;

      UPDATE `rsvp` {updated params} WHERE `EMAIL`= {email}

      1. fireflyimageworks Avatar
        fireflyimageworks

        Oh man… talk about quick response. Thanks for this!
        Maybe it’s the 2:30am getting to me, but any suggestions where in your code I might plug that in?

        1. Travis h Avatar

          Line 148 needs to be changed to the sql UPDATE command.

          1. fireflyimageworks Avatar
            fireflyimageworks

            Lifesaver. Thank you, sir. Truly.

          2. Matt Avatar
            Matt

            Were you able to get this to work? I really don’t know sql at all and i’ve been googling like mad. I’d love a copy of this part of your code if you got it to update.

  14. Anja Avatar
    Anja

    Hi Travis, thank you for this!

    How can I add an option that the hosts receive a confirmation e-mail everytime someone rsvp’s?

    Thanks,
    Anja

  15. dan Avatar
    dan

    Hello,

    I have come across this example today and it’s smashing. I am encountering an issue though whereby if I add more guests the ‘submit’ button gets lost and disappears down the bottom. Can anyone help?

    1. Travis h Avatar

      Hi Dan

      Are you displaying the rsvp page in a iframe, if that is the case you will need to make the iframe larger.

      Regards,

      Travis

  16. sol Avatar
    sol

    Hi Travis,
    A great piece of script and so handy and I love it. From what I gathered, the full name field has a restriction for 2 words. How can I lift that restriction and make it accept one word or even one letter? I really appreciate your input. I can figure out if you just tell me which line in script to modify. Thanks Travis.

  17. Alicia Avatar
    Alicia

    Travis,

    I’m getting an error on the res page and when trying to view the tables I am getting more errors. I do not know much about PHP to SQL. I would love you long time…for some help!

  18. Alicia Avatar
    Alicia

    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home2/aliciase/public_html/brady.technology/res.php on line 19
    NameAttendGuestsCommentsSong

    1. Travis h Avatar

      Hi Alicia, what version of PHP are you using? Or who are you hosting with?

      1. Jordan Avatar
        Jordan

        I am also getting this error. I host with Certified Hosting but am not sure which version PHP I am using.

        1. Jordan Avatar
          Jordan

          I fixed this issue, I forgot to add the mysql user to the mysql database.

  19. grandeabc Avatar
    grandeabc

    Very nice! Thanks to share!

  20. doctorr Avatar
    doctorr

    Hi there, thanks for sharing this. Question though: If a user chooses “modify existing”, is that supposed to create a new row or edit an existing row? It’s creating a new row for me, so the same guest will have multiple rows if they choose that. Is that how it’s supposed to work?

  21. Michael Avatar
    Michael

    Assume this is server side java as I am getting an error “This page works better with JavaScript enabled.” however not sure where to enable java in apache 2.4x not finding any good google searches either. Otherwise once I figure this out this is a great start for a project I am trying to come up with a simple solution for.

    1. MECTILE Avatar

      Hi Michael, this code is old and hasn’t been recently tested. The JavaScript is client side, and this is some on page load code that hides that message.

  22. Michael Avatar
    Michael

    Thanks I will have to troubleshoot more as your test example on your site works perfect but when downloaded and put on my cantos lamp server it shows the better with java error.

  23. Joe Avatar
    Joe

    Hi I cannot download the SQL file. Please help! Thank you.

    1. MECTILE Avatar

      I’ve updated the link.

Leave a Reply

Your email address will not be published. Required fields are marked *