Page 1 of 1

Interfacing in PHP: Urgent help needed!

Posted: Wed Mar 18, 2009 10:41 pm
by siminder82
Hello everyone.

Im having some trouble with interfacing in PHP. Here's what I need to implement:

I have a php file called main.php which does some processing. It takes input from a html file test.html and prints the output after the processing is over. Now, I need to break away from a point in main.php (on certain condition) and goto another php file file2.php passing some parameters. Now file2.php has an HTML form embedded in it and I need to ask user input using that form (through submit button), take the user input value and go back to the main.php with that value, to carry on the rest of the processing of main.php.

I have tried multiple things but none seems to work. Can anyone please help me and suggest what should I do?

Re: Interfacing in PHP: Urgent help needed!

Posted: Thu Mar 19, 2009 12:50 am
by jaoudestudios
Use sessions.

This will keep your data from page to page.

Re: Interfacing in PHP: Urgent help needed!

Posted: Thu Mar 19, 2009 12:50 am
by php_east
find a small abandoned CMS and modify to suit your needs.

Re: Interfacing in PHP: Urgent help needed!

Posted: Thu Mar 19, 2009 4:27 am
by jaoudestudios
php_east wrote:find a small abandoned CMS and modify to suit your needs.
That might be a bit overkill. No point trying to use a rocket to kill a fly :P

Re: Interfacing in PHP: Urgent help needed!

Posted: Thu Mar 19, 2009 4:48 am
by php_east
yes of course, but i wasn't on about using a jack hammer to kill a mosquito. i was talking about this http://snewscms.com/

Re: Interfacing in PHP: Urgent help needed!

Posted: Thu Mar 19, 2009 5:51 pm
by siminder82
I can use session variables for passing values but here's the concern ive been struggling with

Once I submit the form in file2.php, how do I go back to the main.php page at the point where I broke off.

I tried using include_once and also header("location:file2.php") to break from main.php but nothing seems to work.

Is there another way I can do it or is it not possible?

Re: Interfacing in PHP: Urgent help needed!

Posted: Fri Mar 20, 2009 12:48 am
by jaoudestudios
Not entirely sure what you mean, but you could always use ajax, that way you never leave the page.

Re: Interfacing in PHP: Urgent help needed!

Posted: Fri Mar 20, 2009 2:03 am
by php_east
siminder82 wrote:I can use session variables for passing values but here's the concern ive been struggling with
Once I submit the form in file2.php, how do I go back to the main.php page at the point where I broke off.
I tried using include_once and also header("location:file2.php") to break from main.php but nothing seems to work.
Is there another way I can do it or is it not possible?
since you have a form where the user needs to fill in, in file2, that form action should be set to main.php.

in main.php you should now test if there is a non empty form value.
for example, if you have a field

Code: Select all

<input type="text" id="my_user_input" value="" />
on the form, then you know a blank means no user input. so you could test

Code: Select all

if (empty($_POST['my_user_input']))
{
//proceed with processing part 1
}
else
{
//proceed with further processing
}
 
in your main.php