Jump to content

Linking $id To Form Submit


justlukeyou

Recommended Posts

I have a form which people can submit information to and then creates a unique ID number.  I then echo the form results onto another page.  I also want to use the unique id within a link however it echos every id in the database and not just the unique id of the newly submitted form.

 

For example, on 100th submit:

 

For Submit: hello my name is Tom.

 

Echo:          $comment      hello my name is Tom.

                  $id                1009998979695949392919089.................

 

Can anyone advise how I can get it so echo just the id number which refers to this submission. IE "hello my name is Tom"

Link to comment
Share on other sites

Hi,

 

This is the code.

 

// Get values from form 
$category = $_POST['category'];
$question=$_POST['question'];
$notes=$_POST['notes'];

// Insert data into mysql 
$sql="INSERT INTO $tbl_name(category, question, notes)VALUES('$category', '$question', '$notes')";
$result=mysql_query($sql);




// if successfully insert data into database, displays message "Successful". 
if($result){
echo "<a href= 'http://www.domain.com/test/index.php'>$question</a></br>
$notes</br>
$category";
}




else {
echo "Apologies, there appears to be a problem.  Your questions was not been submitted.";
}


ini_set('display_errors', 1);
error_reporting(-1);

{
$query = "SELECT * FROM home";
}

$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))

{
$id = $row['id'];
echo "<a href= 'http://www.domain.com.php?question='>$id</a>";
}



// close connection 
mysql_close();

Link to comment
Share on other sites

You can get anythink you want, as it all in a database.

 

I looked at your code and was baffled at all the insucure programming.

 

maybe your self tualt, but you need a good tutoral,sorry but none off the var are protected for fake inserts from ppl.

 

look at this.

 

select what_ever from what_ever where id="what_ever"

 

that easy.

 

 

 

 

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.