HTTP_REFERER not giving proper results

From: Date: Fri, 12 Jan 2001 23:49:24 +0000
Subject: HTTP_REFERER not giving proper results
Groups: php.general 
Request: Send a blank email to php-general+get-34306@lists.php.net to get a copy of this message
PHP gurus, I am having a page named scene1.php, which got link to playvoice.php, one drop down list box and a submit button. I will try to explain what i want from this page as much clearly as possible with the following points. 1. Scene1.php appears on the user screen after it gets redirected from a page named redirect1.php 2. Initially there won't be any submit button and the page will have only link to playvoice.php and the dropdown list box. 3. After the user clicks on the 'Play voice file' link which leads to playvoice.php, he will go to phpvoice.php which shows just one line like 'Played a voice file' for about 3 seconds on the user screen and he will be redirected back to scene1.php 4. Now the latest scene1.php won't have a 'Play voice file' link but just a text 'Play voice file', dropdown box and now the submit button appears on the screen. 5. As the user clicks on the submit button, the opinion will enter into the database and a link 'Go to the next scenario' appears on his screen, after he clicks it he will go to redirect2.php. Now what my problem is the logic which i wrote within the if statement(code is below) is not working, but directly the logic within the else statement is appearing on the user screen(step 4 is coming directly instead of step 2 coming first), which is preventing the user from clicking on the link 'Play voice file'(as there is no link at all, just text). So what i feel is the $HTTP_REFERER variable is not catching redirect1.php into it. I want to know where i am going wrong in using that. Thanks a lot to whoever responds Chakravarthy K Sannedhi <html> <head> <title>Scenario 1 Best Effort</title> </head> <body> <?php print ("<body>"); mysql_connect('localhost','user','password') or die ('<b>unable to connect to the database.</b>'); mysql_select_db ('nimitztest') or die ('<b>unable to select the database.</b>'); if (!$submit || !$error) { ?> <center><h2><font face=Times New Roman color=#3399ff>Scenario 1</font></h2></center> <p>This scenario includes best effort network, without any congestion. The queing is set to First In First Out(FIFO) and there is no reservation made for voice. Now please click on the link below to play the voice file and later submit your opinion on the quality of voice.</p> <form action=<?php echo $PHP_SELF ?> method=post> <?php global $HTTP_REFERER; if ($HTTP_REFERER == "http://www.myserver.com/redirect1.php") { print ('<a href=playvoice.php>Play voice file</a>'); print ('<p>'); print ('<select name=opinion>'); print ('<option value=rate>(Rate it!)</option>'); print ('<option value=1>1</option>'); print ('<option value=2>2</option>'); print ('<option value=3>3</option>'); print ('<option value=4>4</option>'); print ('<option value=5>5</option>'); print ('</select>'); } else { print ('Play voice file'); print ('<p>'); print ('<select name=opinion>'); print ('<option value=rate>(Rate it!)</option>'); print ('<option value=1>1</option>'); print ('<option value=2>2</option>'); print ('<option value=3>3</option>'); print ('<option value=4>4</option>'); print ('<option value=5>5</option>'); print ('</select>'); print ('<center><input type=submit name=submit value=submit your opionion></center>'); flush(); print ('</form>'); } } if ($submit) { if ($opinion=='rate') { $error="Please select the rating"; echo $error; } else { $result = mysql_query("select * from testtakerinfo order by userid desc limit 1"); $myrow = mysql_fetch_array ($result); $id = $myrow["userid"]; $query = "update testtakerinfo set scene1='$opinion' where userid=$id"; mysql_query ($query); echo "<a href=redirect2.php>Go to next scenario</a>"; } } include ('includefile.php'); ?> </body> </html> __________________________________________________ Do You Yahoo!? Yahoo! Photos - Share your holiday photos online! http://photos.yahoo.com/

« previous php.general (#34306) next »