Solved

can I have a form that posts to itself within a function

Posted on 2011-03-09
9
280 Views
Last Modified: 2012-05-11
public function viewProductFolder($folderid) {

<form action="products.php?a=vpf&fid='.$folderid.'" method="POST" id="archiveform">

<input type="submit" value="save form">
</form>
}

when I press submit I am taken to the correct url, but there is no data on the page

can I have a form that posts to itself within a function
0
Comment
Question by:rgb192
  • 4
  • 4
9 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 35085722
You can but you have to re-write the data to the form or page yourself.  It won't be automatic.
0
 

Author Comment

by:rgb192
ID: 35085769
how... and where
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 35085895
Here is a simple demo.  If you enter your name and class in lower case, you will see it posted in uppercase when you click on submit.  I did that so I could tell that it was being submitted.
<?php
$std_id = "Your Name"; 
$std_cls = "Your Class";
$age = "Age";
$gender = "Gender"; 

if(isset($_POST['submit'])) {
		$std_id = strtoupper($_POST['student']); 
		$std_cls = strtoupper($_POST['class']);
		$age = $_POST['age'];
		$gender = $_POST['gender']; 
		}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Form1</title>
</head>
<body>
<h1>First Form</h1>
<h3>Form info:</h3>
<form action="formFx.php" method="post">
Student: <input type="text" name="student" value="<?php echo $std_id; ?>" /><br />
Class:   <input type="text" name="class" value="<?php echo $std_cls; ?>" /><br />
Age:     <input type="text" name="age" value="<?php echo $age; ?>" /><br />
Gender:  <input type="text" name="gender" value="<?php echo $gender; ?>" /><br />
</pre>
<input type="submit" name="submit" value="Submit" />

</form>
</body>
</html>

Open in new window

0
 

Author Comment

by:rgb192
ID: 35086007
I understand your example (form that posts to iteself)

but I dont understand what you mean

>>You can but you have to re-write the data to the form or page yourself.  It won't be automatic.

a form within a function


maybe
if(isset($_POST['submit'])) {
repeat form again
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 35086173
You said "when I press submit I am taken to the correct url, but there is no data on the page".  I showed you how to put data on the page which you apparently already understand.  And "can I have a form that posts to itself within a function".  Posting to itself is easy but if you want to include it in a function, you do have to add the logic to do that and it has to be on the next page.  If you were inserting variables in the form function above, you just have to get them from the POST variables like I did.
0
 

Author Comment

by:rgb192
ID: 35086450
the page recreates itself when I go to
products.php?a=vpf&fid=43

but when I press submit
the page goes to
products.php?a=vpf&fid=43

but it is a blank page
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 35086619
You need to look at your control statements like 'if' and 'case' to see what is blocking it.  Look at the code where you function is being called.
0
 
LVL 5

Accepted Solution

by:
onemadeye earned 500 total points
ID: 35086668
Perhaps empty the form action to :
<form action="" method="POST" id="archiveform">

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 35124826
took out the id and it works
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now