...

View Full Version : Hard to say in one line !!



Peuplarchie
07-07-2007, 05:59 PM
Good day to you all,
I'm in a situation where I have 12 pages (month page)
where the user can add to the page on demand.

This is very simple, no problem to do, but I need more then that.

There is 3 way of adding to the file, 3 different template.
- with image
- Without image
- With a country flag, as image


Each template is in 2 step :
- Form
- action-page.php


My problem is that depending on which month the user wants to add to, the "action-page.php" should add to this one.

I mean the fopen within the "action-page.php" should have the month page to open and add to.

Can someone please point me or help me with this !

If you need more info or see my code let me know !
Thanks!

mlseim
07-07-2007, 09:59 PM
Your form will be something like this:

<form action="action-page.php" method="post">
<select name="month">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
</select>
<input type="submit" name="submit" value="submit">
</form>


Your PHP script will start out like this :



<?php
// read the month value from the form
$month=$_POST['month'];

//now that you have the month, you can build a
//variable to define the directory or file.
//you didn't specify how you are naming your files,
//buy I assume the month is part of the filename:

$filename=$month."_file.txt";

//open it and do what you want with it.
?>


Other than that ... not enough information to provide anything else.

Peuplarchie
07-07-2007, 10:09 PM
I need to pass the value posted on a 3rd page, that's my problem.

My files are named by months yes, but they are numbered, which is not a problem here.

But that code would work if it would a been posted on a 3rd page where I can save it, cause my editor is another file I have another file that save to file.

You just need to ask what you want to know, you never loose to ask...

mlseim
07-08-2007, 03:11 AM
If you're entering the 3rd page from a form,
use a hidden value on the form that you then
read on the 3rd page.

You can pass a variable from a form, or from a URL.
You can read the variable with:
$_GET['variable'];
or
$_POST['variable'];
It all depends on how you are transferring it ...

We don't know how you are getting from page 2 to page 3.

"You just need to know what you're asking for, you lose by not asking ..."

Peuplarchie
07-08-2007, 03:44 AM
yes from a form.

mlseim
07-08-2007, 08:33 PM
On the 2nd page, use <input type="hidden" name="var1" ... > and populate
that form with the variables you need to pass onto the 3rd page.

On the 3rd page, grab those hidden variables along with the other ones.

$var1='$_POST['var1'];
(or whatever you call your hidden variables).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum