Copy link to clipboard
Copied
Hi,
I am creating a book website where people can reserve books (one at a time).
Basically what I want to do is have a reserve button under each book which contains hidden values (the title and author of the book) and when they click on the button they will be taken to a 'reserve book' page with a form on it where they will have to fill out their details. However I want the book title and author to automatically be entered into the appropriate fields, so to save the users from having to do it themselves.
I'm sure this is possible with PHP, but not sure how to go about it in the right way.
I would appreciate any help with this.
Thanks
Copy link to clipboard
Copied
Hi
From your original form when it goes to the second page simply process the 1st form data using -
$bookName = $_POST["book_name"];
Then insert it into the 2nd form input field by using the input items optional "value" option , e.g. -
<input type="text" name="book_name" size="25" value="<?php echo $bookName ?>">
PZ
Copy link to clipboard
Copied
Thanks for that, however I can't seem to get the first part of the code right. I have the following:
Reserve book button:
<form action="reserve.php" method="post">
<input type="hidden" name="bookName" id="bookName" value="Eclipse" />
<input type="hidden" name="author" id="author" value="Stephenie Meyer" />
<input class="button" type="image" value="send" alt="reserve" src="images/reserve.gif" width="81" height="22"/>
</form>
Reserve book form:
<form action="process-form.php" method="post">
<label for="name">Your Full Name:*</label>
<input type="text" name="name" id="name" />
<label for="telephone">Tel no:*</label>
<input type="text" name="telephone" id="telephone" />
<label for="email">Email:*</label>
<input type="text" name="email" id="email"/>
<label for="Title">Book Title:*</label>
<input type="text" name="book_title" size="25" value="<?php echo $bookName ?>" />
<label for="Author">Author:*</label>
<input type="text" name="author" size="25" value="<?php echo $author ?>" />
<input class="button" type="image" value="send" alt="reserve" src="images/reserve.gif" width="81" height="22"/>
</form>
Copy link to clipboard
Copied
Hi
Why do you have a reserve book form and a separate reserve book button/form?
PZ