Wrox Programmer Forums
|
BOOK: Beginning PHP 5.3
This is the forum to discuss the Wrox book Beginning PHP 5.3 by Matt Doyle; ISBN: 978-0-470-41396-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 5.3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 29th, 2011, 11:00 AM
Authorized User
 
Join Date: Feb 2011
Posts: 25
Thanks: 2
Thanked 1 Time in 1 Post
Default Processing HTML forms

I've looked over the code a zillion times, even downloaded the code for processing an html form. But it just doesn't want to work. After filling in the info and clicking the submit button, instead of going to the process_registration page, where all the info is displayed it opens up the Notepad version of procees_registration. Does anyone have a clue what as to what's wrong?
 
Old July 31st, 2011, 02:15 AM
Authorized User
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you paste all the related code and screenshot ?
 
Old July 31st, 2011, 10:42 AM
Authorized User
 
Join Date: Feb 2011
Posts: 25
Thanks: 2
Thanked 1 Time in 1 Post
Default

This is the html file with the code for the form:

<!DOCTYPE html PUBLIC -"//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Membership Form</title>
<link rel="stylesheet" type="text/css" href="common.css">
</head>
<body>
<h1>Membership Form</h1>

<p>Thanks for choosing to join The Widget Club. To registger, please fill in your details below and click Send Details.</p>

<form action="process_registration.php" method="post">
<div style="width: 30em;">

<label for="firstName">First Name</label>
<input type="text" name="firstName" id="firstName" value=""/>

<label for="lastName">Last Name</label>
<input type="text" name="lastName" id="lastName" value=""/>

<label for="password1">Choose a password</label>
<input type="password" name="password1" id="password1" value""/>

<label for="password2">Retype password</label>
<input type="password" name="password2" id="password2" value""/>

<label for="genderMale">Are you male...</label>
<input type="radio" name="gender" id="genderMale" value="M"/>

<label for="genderFemale">Are you female...</label>
<input type="radio" name="gender" id="genderFemale" value="F"/>

<label for="favoriteWidget">What's your favorite widget?</label>
<select name="favoriteWidget" id="favoriteWidget" size="1">
<option value="superWidget">The SuperWidget</option>
<option value="megaWidget">The MegaWidget</option>
<option value="wonderWidget">The WonderWidget</option>
</select>

<label for="newsLetter">Do you wnat to receive our newsletter?</label>
<input type="checkbox" name="newsletter" id="newsletter" value="yes"/>

<label for="comments">Any comments?</label>
<textarea name="comments" id="comments" rows="4" cols="50"> </textarea>
<div style="clear:both;">
<input type="submit" name="submitButton" id="submitButton" value="Send Details"/>
<input type="reset" name="resetButton" id="resetButton" value="Reset Form" style="margin-right: 20px;"/>
</div>
</div>
</form>

</body>
</html>

and this is the php script to process the form:


<!DOCTYPE html PUBLIC -"//W3C//DTD XHMTL 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Thank You</title>
<link rel="stylesheet" type="text/css" href="common.css">
</head>
<body>
<h1>Thank You</h1>

<p>Thak you for registering. Here is the information you submitted:</p>

<d1>
<dt>First name</dt><dd><?php echo $_POST["firstName"]?></dd>
<dt>Last name</dt><dd><?php echo $_POST["lastName"]?></dd>
<dt>Password</dt><dd><?php echo $_POST["password1"]?></dd>
<dt>Retyped password</dt><dd><?php echo $_POST["password2"]?></dd>
<dt>Gender</dt><dd><?php echo $_POST["gender"]?></dd>
<dt>Favorite</dt><dd><?php echo $_POST["favoriteWidget"]?></dd>
<dt>Do you want to recieve our newsletter?</dt><dd><?php echo $_POST["newsletter"]?></dd>
<dt>Comments</dt><dd><?php echo $_POST["comments"]?></dd>
</dl>

</body>
</html>


Do you have anby idea what's wrong with the code?
 
Old July 31st, 2011, 12:34 PM
Authorized User
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your code is fine. I am guessing that you not put your script under web root so that web server can serve your PHP script.

tell me what is your URL look like for your html form ?

Also, if you include code, use the icon # , < > , and php on the editor to format the code. It will be lots ez to read.


PHP Code:
var $dump NULL
HTML Code:
<h1>hi</h1>
Code:
<script>console.log('hi')</script>
 
Old August 1st, 2011, 05:16 PM
Authorized User
 
Join Date: Feb 2011
Posts: 25
Thanks: 2
Thanked 1 Time in 1 Post
Default

Cheers for the tips on the icons for the code. I checked and my registration is in the web root folder with the process_registration.php
Here's the URL:
C:\wamp\www\registration.html.

Any ideas?
 
Old August 1st, 2011, 06:16 PM
Authorized User
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
C:\wamp\www\registration.html
is the path to your registration.html file. You can not use it in your browser (IE, Firefox, Chrome).

Your local web server should start
Code:
http://localhost
So try to enter
Code:
http://localhost/registration.html
in your browser. Then click the submit.
 
Old August 2nd, 2011, 01:14 PM
Authorized User
 
Join Date: Feb 2011
Posts: 25
Thanks: 2
Thanked 1 Time in 1 Post
Default

Yeah sorry. http://localhost/registration.html is what I write in the browser. the C:/wamp/www/registration.html is the file path. But the result is the same. I click submit, and instead of getting the process_registration.php I get the text editor verion of it.?????
 
Old August 2nd, 2011, 02:00 PM
Authorized User
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You meant when you click submit, the browser downloads the process_registration file ? or it display process_registration as text ?

I need screen shots or video.
 
Old August 4th, 2011, 12:07 PM
Authorized User
 
Join Date: Feb 2011
Posts: 25
Thanks: 2
Thanked 1 Time in 1 Post
Default

I don't know how to get the pictures into this post. But what I mean is that the registration.html form comes up as normal with the form fields to fill in. When I click the submit button to send the details to the process_registration.php script. the webpage doesn't appear. All that comes up is the opened notepad application with the proces_reigistration.php code:.
PHP Code:
<!DOCTYPE html PUBLIC -"//W3C//DTD XHMTL 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
   <head>
      <title>Thank You</title>
      <link rel="stylesheet" type="text/css" href="common.css">
   </head>
   <body>
      <h1>Thank You</h1>

      <p>Thak you for registering. Here is the information you submitted:</p>

      <d1>
        <dt>First name</dt><dd><?php echo $_POST["firstName"]?></dd>
        <dt>Last name</dt><dd><?php echo $_POST["lastName"]?></dd>
        <dt>Password</dt><dd><?php echo $_POST["password1"]?></dd>
        <dt>Retyped password</dt><dd><?php echo $_POST["password2"]?></dd>
        <dt>Gender</dt><dd><?php echo $_POST["gender"]?></dd>
        <dt>Favorite</dt><dd><?php echo $_POST["favoriteWidget"]?></dd>
        <dt>Do you want to recieve our newsletter?</dt><dd><?php echo $_POST["newsletter"]?></dd>
        <dt>Comments</dt><dd><?php echo $_POST["comments"]?></dd>
      </dl>

    </body>
</html>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending info to HTML forms.... Sildaekar C++ Programming 0 April 2nd, 2007 01:24 PM
HTML forms AND Screen resolution prabodh_mishra HTML Code Clinic 2 March 8th, 2006 07:41 PM
Database entry from HTML forms gmoney060 Classic ASP Basics 4 March 31st, 2004 04:50 AM
Mandatory Forms in Html spraveens HTML Code Clinic 1 November 18th, 2003 02:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.