I am trying to write what, in my opinion, will be a very simple PHP RSVP page for my (fast-approaching) wedding. I am learning PHP specifically for this task, and everything was fine until I hit the wall. Below are high-level steps on how I envision this work, as well as the code that I have currently written. I really want to do this this week, so any help would be greatly appreciated.
The user puts the name and surname and clicks the "Search" button. Here is an image of how the form looks. Below is the HTML form.
<form method = "post" action="rsvp.php">
<span>First Name:</span><input type="text" name="firstName" value="Father">
<span>Last Name </span><input type="text" name="lastName" value="Test">
<input type="submit" name="search_submit" value="Search">
</form>
In the "Search" window, click, request a database. The following is the PHP code.
if (isset($_POST['search_submit'])) {
include 'dbconnect.php';
$firstName = $_POST["firstName"];
$lastName = $_POST["lastName"];
$query = "SELECT * FROM guests WHERE PartyID IN (SELECT PartyID FROM guests WHERE FirstName = '$firstName' AND LastName = '$lastName')";
$result = mysqli_query($sql, $query);
if (mysqli_num_rows($result) == 0) {
echo "<p id=" . '"' . "searchError" . '"' . ">Sorry, I couldn't find your name. Try again. If you still have an issue please send me an email.";
}
else {
echo '<form method = "post" action="rsvp.php">
<span class="guestNames">Party Members</span>
<span class="radioButtons">Attending</span>
<span class="radioButtons">Not Attending</span>
<br/>
<br/>
';
while ($row = mysqli_fetch_array($result)) {
echo '<span class="guestNames">' . $row['FirstName']
. ' '
. $row['LastName'] . '</span>
<input type="radio" class="radioButtons" name="' . $row['ID'] . '"value="yes">
<input type="radio" class="radioButtons" name="' . $row['ID'] . '"value="no">
<br />
';
}
echo '<input type="submit" name="rsvp_submit" value="RSVP">
</form>';
}
mysqli_close($sql);
}
- . , "" " ". this.
"RSVP". . . ...
if (isset($_POST['rsvp_submit'])) {
echo 'What do I do now?';
}
- "RSVP" , .
, (, -) , 4. , . , , , , , , . , .