Solved

Including a form page in an action page

Posted on 2004-03-28
5
201 Views
Last Modified: 2006-11-17
Hi,

I am new to php. Hope some kind souls out there can help me out.

Basically, my scenario is that a user can create an account for himself through a form. However, due to some validation, an error message is displayed to him. I would like to include the form page that he had filled up(including whatever values he had entered) below the error message in the action page. I understand that the include function can be used but not quite sure how.

Hope someone can help me out. Thanks.

Rio
0
Comment
Question by:deadmanincsg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Accepted Solution

by:
CosminB earned 125 total points
ID: 10701347
<?php
include 'form.html';
//or
include 'form.php'
?>
http://www.php.net/include
or
http://www.php.net/require
0
 
LVL 17

Assisted Solution

by:dorward
dorward earned 125 total points
ID: 10701836
and edit the form such:

<input name="foo" value="<?php print htmlspecialchars(stripslashes($_REQUEST['foo'])); ?>">

... to preserve the data he submitted.
0
 
LVL 1

Expert Comment

by:mikrotuho
ID: 10798203
Methinks that this scenario could be taken care of with one multipurpose page: thispage.php.
<html>

<?php
if (1==$_GET['isinputok'])://Check to see whether user submitted incorrect information
?>
HTML telling him of his sin
//Since isinputok!=2 then the form will be displayed again. The code by dorward can be used
//to display the form input (I think).
<?php
else:

if (2==$_GET['isinputok']{
//Process form input
if input is wrong then call this page with 'thispage.php?isinputok=1'
if input is ok then do what you need to do
}
?>

//Here we have the form in php or html. This is where the script starts when the page is
//first called (isinputok is not set to anything), or if the user submitted incorrect information.
//ie. isinputok==1.
HTML FORM

//In the action part of the form this same page needs to be called with 'thispage.php?isinputok=2'
//for this to work.

<?php
endif;
}
</html>

I hope this makes some sense to you,

Mikrotuho
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question