Solved

Including a form page in an action page

Posted on 2004-03-28
5
199 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
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 dynamically set the form action using jQuery.

821 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