Jump to content

[SOLVED] SELECT MAX & Pass through URL


jonathanbee

Recommended Posts

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

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";

 

    }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.