View Full Version : How do I post form a hidden to random page

07-31-2007, 05:13 PM
I have this code. The red colored links represent the randomized links i intend the to have the forms posted to. I just need to know if someone could please write the code needed to apply this code or something like it. Essentially I just need the page forwarding script to execute and move some variables in a hidden form to the page that it is directed to go to via the forwarding script. So the red links need to fill the green spot on the form. But i also need the form to be submitted automatically. I don't know any better way to explain it.

I will also need to know how to put the randomURL into the method area, i have tried several things it just does not want to work. If anyone wants to jump in on this one for assistance please help.

I am somewhat new to things and my understanding of terminology is still lacking, so I pretty much have to google things if I have difficulty coding it myself. If I cant find it on google I proceed to ask on forums as a last resort. Any help with this would be extremely appreciated.

<script language="JavaScript">
day = new Date();
hr = day.getSeconds();
if ((hr >= 0) && (hr <= 6)) {
randomURL = "http://cherry.com/chatroom.php"; }
if ((hr > 6) && (hr <= 12)) { randomURL = "http://apples.com/chatroom.php"; }
if ((hr > 12) && (hr <= 18)) { randomURL = "http://blah.com/chatroom.php"; }
if ((hr > 18) && (hr <= 24)) { randomURL = "http://pears.com/chatroom.php"; }
if ((hr > 24) && (hr <= 30)) { randomURL = "http://grapes.com/chatroom.php"; }
if ((hr > 30) && (hr <= 36)) { randomURL = "http://desksandchairs.com/chatroom.php"; }
if ((hr > 36) && (hr <= 42)) { randomURL = "http://peaches.com/chatroom.php"; }
if ((hr > 42) && (hr <= 48)) { randomURL = "http://tigerlillies.com/chatroom.php"; }
if ((hr > 48) && (hr <= 54)) { randomURL = "http://foriegner.com/chatroom.php"; }
if ((hr > 54) && (hr <= 60)) { randomURL = "http://pianos.com/chatroom.php"; }
document.write("<meta http-equiv='refresh' content='3;url=" + randomURL + "'>");
// -->

<form action="The spot where forwarding link goes" method="post">
<br><input type="hidden" name="variable1" value="<? echo $_POST['blah']; ?>">
<br><input type="hidden" name="variable2" value="<? echo $_POST['hmmmm']; ?>">
<br><input type="submit" value="Submit!">

08-01-2007, 03:23 AM
I guess everyone is sleeping today.:confused:

08-01-2007, 02:19 PM
Hmm, I'm a little confused here - is the form on the page the javascript refreshes to?

08-01-2007, 03:54 PM
It's not suppossed to refresh. It's supposed to have a different load for each interval.

08-01-2007, 04:01 PM
I understand that...what I'm asking is which page the form is on...?

08-01-2007, 05:18 PM

document.FORMNAME.action='somepage.html' ;


document.getElementById('FORMID').action='somepage.html' ;

...not work?!?!?

08-02-2007, 03:15 PM
The form is supposed to be hidden into "the page forwarding script" page. I just need a way to have varialbles from a previous form to be passed through the page with the page forwarding script. Inserting a a "hidden form" so that automatically submits into the "page forwarding script page" so that the end page receives the variables. I figured would be the best way... however figuring out how to do it is another thing.

Heres an example (http://s66.photobucket.com/albums/h263/clonesoft/websters/?action=view&current=helpme1.jpg)

08-02-2007, 05:54 PM
Alright, what server side language are you using?

08-02-2007, 06:41 PM
Its a php website.

OS: Debian Linux
PHP Ver: 5.1.6
MySQL Ver: 5.0.27

08-03-2007, 02:04 AM
Alright, then why're you using javascript for this?

<?php session_start();

$_SESSION['blah'] = isset($_POST['blah']) ? $_POST['blah'] : 'empty';
$_SESSION['hmm'] = isset($_POST['hmm']) ? $_POST['hmm'] : 'empty';

$hr = date('s');

if($hr >= 00 && $hr <= 6){ $randomUrl = 'http://cherry.com/chatroom.php';}
if($hr > 6 && $hr < 12){ $randomUrl = 'http://apples.com/chatroom.php';}
//and so on



Ok, so now what we've done is replaced all javascript and made a way to save the info sent through the form on the previous page. We've set sessions so that on, say, cherries.com/chatroom.php we can do this:

<?php session_start();

$blah = isset($_SESSION['blah']) ? $_SESSION['blah'] : 'no blah session!';
$hmm = isset($_SESSION['hmm']) ? $_SESSION['hmm'] : 'no hmm session!';


<h1>Welcome, I just wanted to say <?=$blah ?></h1>
<h1>Oh, and by the way...<?=$hmm ?></h1>

If you want any of this explained, just ask. You must have the session_start(); before any content is echoed. (It's easy to just drop it right after the opening php tags)

Hope this helps.

08-03-2007, 02:17 AM
You could do this more easily with just using an actual random link. I'm not sure if there is some other reason you want it to relate to the seconds, though.

$a = array('link1','link2','link3');
$randurl = $a[mt_rand(0,count($a))];

That's it...

08-03-2007, 03:29 AM
Thanks both of you, I will definately give these a try.

08-03-2007, 07:18 AM
Hi alexjewell

I put codes in the right pages.

I get the errors

Cannot send session cookie - headers already sent by

Cannot send session cache limiter - headers already sent

Im not sure what is going on

08-05-2007, 05:51 AM
I get the following error

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /www/110mb.com/c/l/o/n/e/x/_/_/clonex/htdocs/join.php:1) in /www/110mb.com/c/l/o/n/e/x/_/_/clonex/htdocs/join.php on line 1

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /www/110mb.com/c/l/o/n/e/x/_/_/clonex/htdocs/join.php:1) in /www/110mb.com/c/l/o/n/e/x/_/_/clonex/htdocs/join.php on line 1

Warning: Cannot modify header information - headers already sent by (output started at /www/110mb.com/c/l/o/n/e/x/_/_/clonex/htdocs/join.php:1) in /www/110mb.com/c/l/o/n/e/x/_/_/clonex/htdocs/join.php on line 20

Im looking for any whitespace yet I can't find any. Im trying to think of what I may be doing wrong.

<?php session_start();

$_SESSION['nick'] = isset($_POST['nick']) ? $_POST['nick'] : 'empty';
$_SESSION['server'] = isset($_POST['server']) ? $_POST['server'] : 'empty';
$_SESSION['room'] = isset($_POST['room']) ? $_POST['room'] : 'empty';

$hr = date('s');

if($hr >= 00 && $hr <= 6){ $randomUrl = 'http://websters.freehostingnow.com/zendurl.php';}
if($hr > 6 && $hr < 12){ $randomUrl = 'http://websters.freehostingnow.com/zendurl.php';}
if($hr >= 12 && $hr <= 18){ $randomUrl = 'http://websters.freehostingnow.com/zendurl.php';}
if($hr > 18 && $hr < 24){ $randomUrl = 'http://websters.freehostingnow.com/zendurl.php';}
if($hr >= 24 && $hr <= 30){ $randomUrl = 'http://websters.freehostingnow.com/zendurl.php';}
if($hr > 30 && $hr < 36){ $randomUrl = 'http://websters.freehostingnow.com/zendurl.php';}
if($hr >= 36 && $hr <= 42){ $randomUrl = 'http://websters.freehostingnow.com/zendurl.php';}
if($hr > 42 && $hr < 48){ $randomUrl = 'http://websters.freehostingnow.com/zendurl.php';}
if($hr >= 48 && $hr <= 54){ $randomUrl = 'http://websters.freehostingnow.com/zendurl.php';}
if($hr > 54 && $hr < 60){ $randomUrl = 'http://websters.freehostingnow.com/zendurl.php';}



08-08-2007, 12:36 AM
Days later, I still try various ways to get this working, however it is still not working. Can someone with php knowledge assist please?

08-08-2007, 02:31 AM
Alright, is there any code before the php block?

To fix the header issue, do this:


The session thing I can't figure out if there's nothing before it on the page. Is this included in anything or is anything echoed before it??

08-08-2007, 06:36 AM
Thanks again for the assistance. The entire source code is what you see in the quotes.

P.S. The links you see will be changed later, I am just using one link for now for the purpose of testing.

08-08-2007, 06:45 AM
You need to place the code at the very top of your page. Even before the <html> and <!DOCTYPE tags.

08-08-2007, 07:12 AM
Tech? Would that be the entire code, or just part of it?

08-08-2007, 07:17 AM
The entire code.

08-08-2007, 04:02 PM
The page doesnt have any of the doctype tags or head, or body.

08-09-2007, 06:47 AM
Try adding this error_reporting(E_ALL);before session_start(); and paste the errors here.

08-09-2007, 02:01 PM
Yeah, if anything is echoed before the session_start(); then those header errors show up. Now, it's usually the same with header(), too, but with the code I gave you it stops that for some reason and it still works.

As tech said, add the error_reporting before the session_start and let us see what happens.