Solved

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

Posted on 2011-03-09
9
283 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
[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
  • 4
  • 4
9 Comments
 
LVL 83

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 83

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
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!

 

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
 
LVL 83

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 83

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

Technology Partners: 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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

752 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