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

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.
  • Pingback: Need free rsvp php script - Software Development()

  • Krodami

    Awesome, just what i was looking for, thank you

  • Jimmer

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

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

  • 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

  • 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?

  • 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.

  • 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.

  • Pingback: Perl script installation service()

  • Sean

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

  • 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.

  • 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?

  • 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.

  • 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.

  • doncamillo

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

  • 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

  • Shaun Middlebusher

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

  • 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)…

  • 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?

  • 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!

  • 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}

  • 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?

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

  • fireflyimageworks

    Lifesaver. Thank you, sir. Truly.

  • 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.

  • 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

  • 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?

  • 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

  • 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.

  • 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!

  • 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

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