Solved

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

Posted on 2011-03-09
9
281 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 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Permalink issue in Wordpress archive 1 32
count download link and run update query 9 54
incrementing radio button names and ids using php 5 36
WordPress syntax 2 23
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

943 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

4 Experts available now in Live!

Get 1:1 Help Now