generate a registration id and display it after successful r

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cipher143
Forum Newbie
Posts: 1
Joined: Wed Aug 28, 2013 5:34 am

generate a registration id and display it after successful r

Post by cipher143 »

i am trying to develop a registration form where the user fill the form and submit it and the id should be displayed once the registration is successful.
i have used uniq_id function to generate a random id and with the help of this reference id i can retrieve the actual ID and display it back to the user. But unfortunately i am successful with the first registration after the first registration it throws an error that

Error: "Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 9".

my code:

Code: Select all

<?php
include(conn.php);
$id = $_GET['id'];
$adv = $_GET['adv'];
$name = $_GET['name'];
$address = $_GET['address'];
$pincode = $_GET['pincode'];
$email = $_GET['email'];
$fax = $_GET['fax'];
$mobile = $_GET['mobile'];
$amount = $_GET['amount'];
$ddchno = $_GET['ddchno'];
$bank = $_GET['bank'];
 
$register = mysql_query( "insert into exbadv ( refid,adv,name,address,pincode,email,fax,mobile,amount,ddchno,bank) 
            values ('$id','$adv','$name','$address','$pincode','$email','$fax','$mobile','$amount','$ddchno','$bank')");
 
$id = $_GET['id'];
$result = mysql_query("SELECT id FROM exbadv WHERE refid = '$id'");
echo 'Your Registration id is ';echo mysql_result($result,0);
?>
Plz help me out,thank u.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: generate a registration id and display it after successf

Post by Celauran »

So you want mysql_insert_id?

More importantly, look at the notice at the top of that page. The mysql_ extension has been deprecated and will be removed from PHP. Do yourself a favour and use PDO instead. Also, sanitize your inputs!
Post Reply