Advanced Search

Results 1 to 2 of 2

Thread: Get Mysql data in to text field

  1. #1
    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    36
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Get Mysql data in to text field

    Hi, i have in my DB a field that is named "Idkod".
    And on my Website i have a Regisration form (Only a mail form, but when submitted this mailform creats a Idkod (10 digits).
    And also on my Webpage i have a anwering mailform and in this mailform i whant a textfiled whare the reg,user have to enter the 10 didgit Idkod they recived on regisration, and i also whant when clicking submit the mailform to check the DB if that Idkod is in the DB, if so than redirect to thankyou page, if not then redirect to error page.

    Thank you.

    /Patrik.

  2. #2
    Join Date
    Oct 2008
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts

    Default

    i would suggest using a rand() in your php code

    PHP Code:
    <?php
    if (isset($_POST['Submit'])) { 
        
    //$random = rand(100000,999999); <-- Generate random number for them. OR
        //$raddom = $_POST['idkod']; <-- Use the input field to check against database
        
    $result mysql_query("SELECT idkod from table where idkod = $random");
        
    $row mysql_fetch_array($result)
        if(
    $row == $random) {
            echo 
    "That number already exist";
        } else {
            
    query statement for insertsend emailthen redirect.
        }
    }
    <
    input id="idkod" type="input">
    <
    input type="button" value="submit">
    Hope this helps. You can figure out the rest.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •