Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PHP remember Form-button data to insert into form field

Guest
Mar 24, 2010 Mar 24, 2010

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

TOPICS
Server side applications
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 24, 2010 Mar 24, 2010

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

www.pziecina.com

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 24, 2010 Mar 24, 2010

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 25, 2010 Mar 25, 2010
LATEST

Hi

Why do you have a reserve book form and a separate reserve book button/form?

PZ

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines