• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

Including a form page in an action page

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
deadmanincsg
Asked:
deadmanincsg
2 Solutions
 
CosminBCommented:
<?php
include 'form.html';
//or
include 'form.php'
?>
http://www.php.net/include
or
http://www.php.net/require
0
 
dorwardCommented:
and edit the form such:

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

... to preserve the data he submitted.
0
 
mikrotuhoCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now