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

 

    }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.