jonathanbee Posted October 2, 2007 Share Posted October 2, 2007 Hi, sorry for another stupid question, but I'm really stumped. I can't seem to get the maximum value of r_id to get to the next page. Please help.. <? require('includes/initialise.php'); $message = ""; $emailclass = "basictext"; if ($_POST['process'] == 1) { $pattern = '/.*@.*\..*/'; $email = $_POST['email']; $urlname = urlencode($_POST['$r_id']); if (preg_match($pattern, $_POST['email']) > 0) { $query = "Insert into res (email) values ('$email')"; $result = mysql_query($query) or die("Insert failed"); $query2 = mysql_query("SELECT MAX(`r_id`) FROM `" . res . "`"); $r_id = mysql_result ($query2, 0); header("location: thankyou.php?&r_id=$urlname"); } $message = "Please enter a valid email address."; $emailclass = "errortext"; } ?> thankyou.php: <?php require('includes/initialise.php'); $r_id = $_GET['$r_id'] ?> <body> <?php echo $r_id;?>です。<br> Link to comment https://forums.phpfreaks.com/topic/71474-solved-select-max-pass-through-url/ Share on other sites More sharing options...
jonathanbee Posted October 2, 2007 Author Share Posted October 2, 2007 got it.. changed it to this: if ($_POST['process'] == 1) { $pattern = '/.*@.*\..*/'; $email = $_POST['email']; if (preg_match($pattern, $_POST['email']) > 0) { $query = "Insert into res (email) values ('$email')"; $result = mysql_query($query) or die("Insert failed"); function getMaxOrderNumber($db) { $result = $db->execute("SELECT MAX(`r_id`) FROM `" . res . "`"); return $result->fields['MAX(`r_id`)']; } $orderNumber = getMaxOrderNumber($db); $r_id = $orderNumber; $urlname = urlencode($r_id); header("location: thankyou.php?&r_id=$urlname"); } $message = "Please enter a valid email address."; $emailclass = "errortext"; } Link to comment https://forums.phpfreaks.com/topic/71474-solved-select-max-pass-through-url/#findComment-359880 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.