ballhogjoni Posted April 27, 2007 Share Posted April 27, 2007 Is there a function that will gather the current URL and then add a number to the end of it? Ex. http://xxxx.com/xxx.php?page=(script to add a number here.) Link to comment https://forums.phpfreaks.com/topic/48952-url-question/ Share on other sites More sharing options...
The Little Guy Posted April 27, 2007 Share Posted April 27, 2007 Like this? http://xxxx.com/xxx.php?page=1 $page = $_GET['page']; echo $page; // returns 1 Link to comment https://forums.phpfreaks.com/topic/48952-url-question/#findComment-239827 Share on other sites More sharing options...
ballhogjoni Posted April 27, 2007 Author Share Posted April 27, 2007 yes but how do you set $_GET['page']; without a form? Link to comment https://forums.phpfreaks.com/topic/48952-url-question/#findComment-239831 Share on other sites More sharing options...
The Little Guy Posted April 27, 2007 Share Posted April 27, 2007 if you want to use a link, just do this: <a href="http://xxxx.com/xxx.php?page=1">Click Me!</a> Link to comment https://forums.phpfreaks.com/topic/48952-url-question/#findComment-239834 Share on other sites More sharing options...
ballhogjoni Posted April 27, 2007 Author Share Posted April 27, 2007 Maybe I am not asking it right. I want to auto redirect to page 2, page 3, and so on depending on what page they are on. So if they are on page 2 and they click submit, I want it to go to page 3 automatically, but the form action="" tag has to go to the same page they submitted from because thats where all my php script is. Link to comment https://forums.phpfreaks.com/topic/48952-url-question/#findComment-239837 Share on other sites More sharing options...
V34 Posted April 27, 2007 Share Posted April 27, 2007 If Header isn't set, you can use header("Location: xxx.php?page=$randomValue"); Link to comment https://forums.phpfreaks.com/topic/48952-url-question/#findComment-239841 Share on other sites More sharing options...
The Little Guy Posted April 27, 2007 Share Posted April 27, 2007 Like this? <?php $newPage = $_GET['page']++; ?> <form action="<?php echo $_SERVER['PHP_SELF'] . '?page=' . $newPage; ?>"> ... </form> Link to comment https://forums.phpfreaks.com/topic/48952-url-question/#findComment-239846 Share on other sites More sharing options...
ballhogjoni Posted April 27, 2007 Author Share Posted April 27, 2007 Ok this is what i have: <?php define("DEFAULT_REDIRECT", "\"".$_SERVER['PHP_SELF']."?page=$i\""); // $i is defined ealier in the script function redirect($filename=DEFAULT_REDIRECT, $delay="0", $die="0") { if((!headers_sent())&&($delay=="0")) { header("Location:$filename"); } elseif($delay=="0"){ echo "<script type=\"text/javascript\">"; echo "window.location.href=\"".$_SERVER['PHP_SELF']."?page=$i\""; echo "</script>"; echo "<noscript>"; echo "<meta http-equiv=\"refresh\" content=\".0;url=".$filename."\">"; echo "<noscript>"; } else { echo "<meta http-equiv=\"refresh\" content=\"".$delay.";url=".$filename."\">"; } } if (isset($too_small)) { $sql = mysql_query("SELECT * FROM contact_n_questions LIMIT $from, $max_results"); while($row = mysql_fetch_array($sql)){ if (isset($row['fname'])) { mysql_query("INSERT INTO dispo_tooSmall (fname, lname, position, email, state, areacode, prefix, linenumber, question1, question2, question2q1, question2q2, question2q3, question2q4, question2q5, question2q6, question3, question4q1, question4q2, question4q3, question4q4, question4q5, question5q1, question5q2, question5q3, question5q4, question5q5, question5q6, question6, question7, question8, question9, tandc, comments) VALUES ('$row[fname]','$row[lname]','$row[position]','$row[email]','$row[state]','$row[areacode]','$row[prefix]','$row[linenumber]','$row[question1]','$row[question2]','$row[question2q1]','$row[question2q2]','$row[question2q3]','$row[question2q4]','$row[question2q5]','$row[question2q6]','$row[question3]','$row[question4q1]','$row[question4q2]','$row[question4q3]','$row[question4q4]','$row[question4q5]','$row[question5q1]','$row[question5q2]','$row[question5q3]','$row[question5q4]','$row[question5q5]','$row[question5q6]','$row[question6]','$row[question7]','$row[question8]','$row[question9]','$row[tandc]','$comments')"); //mysql_query("DELETE FROM contact_n_questions WHERE email='$row[email]'"); redirect("\"".$_SERVER['PHP_SELF']."?page=$i\""); } elseif (!isset($row['fname'])) { echo "<p align=\"center\">Don't Forget To Disposition the Lead.</p>"; } else { echo "<p align=\"center\"><font color=\"red\"><b>What the crap, an error! Go talk to Chris</b></font></p>"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/48952-url-question/#findComment-239868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.