Printing some results on screen when submit is selected

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

mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Printing some results on screen when submit is selected

Post by mohson »

I use the code below to add a new organisation to my organisations table. Part of the organisation is the org_id which is auto incremented.

I then add a person to the people table the person requires the org_id of the organisation it is linked with.

This requires the user to search for the organisation, note down the org_id and then go an add the person record.

This is pointless.

So I want to do this:

Currently when the user adds the organisation and clicks submit my system loads a blank form, BUT I want it to load a blank form and print the org_id.

Can anyone help with this?

This is the process file which adds the record once the user clicks the submit button in the original form.

Code: Select all

<?php
/* Connecting, selecting database */
$link = mysql_connect("xxxx", "xxx", "xxxx")
   or die("Could not connect : " . mysql_error());

mysql_select_db("contact_management_system",$link) or die("Could not select database");
 $sql = "INSERT INTO organisations (org_id,person_id, orgname, web_url, notes ) VALUES ('$org_id','$person_id','$orgname','$web_url', '$notes')";
 if ($result = mysql_query($sql,$link)) {
    header ("location:http://www.soi.city.ac.uk/organisation/pl/CMS/Uorgs.html?Sent=true");
} else {
    die ( mysql_error($link));
} 

?>
By the way if you are wondering whats purpose

Code: Select all

Sent=true
serves, well the below should make it self explanatory

Code: Select all

if ((isset($_GET['Sent'])) and ($_GET['Sent'] == 'true')) { echo '<b><font color="#FF0000">New Organisation Added, Add Another? Remember to Search for the Organisation and note the OID before Adding the Person Linked to the created Organisation</font></b>'; }

Any help would be appreciated
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

Use Header Location
location:http://www.soi.city.ac.uk/organisation/ ... id=$org_id

And

Code: Select all

if ((isset($_GET['Sent'])) and ($_GET['Sent'] == 'true')) { echo '<b><font color="#FF0000">New Organisation Added, Add Another? Remember to Search for the Organisation and note the OID before Adding the Person Linked to the created Organisation</font></b> Your id is $_GET[id]'; }
=========================================================
But its Not Safe To Pass Such Arguments With GET Method
You Can Use Cookies And Forward To A Page That Will Get Values From That Cookies
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

I used

Code: Select all

header ("location:http://www.soi.city.ac.uk/organisation/pl/CMS/Uorgs.html?Sent=true&id=$org_id");
And

Code: Select all

<?php
if ((isset($_GET['Sent'])) and ($_GET['Sent'] == 'true')) { echo '<b><font color="#FF0000">New Organisation Added, Add Another? Remember to Search for the Organisation and note the OID before Adding the Person Linked to the created Organisation</font></b>Your org id is $_GET[id]'; }
?>
And all it does is load a blank form with the above message and the words
Your org id is $_GET[id]
Any Ideas
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

Use This Code

Code: Select all

<?php 
if ((isset($_GET['Sent'])) and ($_GET['Sent'] == 'true')) { echo '<b><font color="#FF0000">New Organisation Added, Add Another? Remember to Search for the Organisation and note the OID before Adding the Person Linked to the created Organisation</font></b>Your org id is'.$_GET[id]; } 
?>
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

This time it prints
Your org id is
Why is it not printing the org_id that was just updated?
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

Is It Printing The

new Organisation Added, Add Another? Remember to Search for the Organisation and note the OID before Adding the Person Linked to the created Organisation
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

Save The Page Where The
<?php
if ((isset($_GET['Sent'])) and ($_GET['Sent'] == 'true')) { echo '<b><font color="#FF0000">New Organisation Added, Add Another? Remember to Search for the Organisation and note the OID before Adding the Person Linked to the created Organisation</font></b>Your org id is'.$_GET[id]; }
?>
Is As some_file_name.php

And Use
header ("location:http://www.soi.city.ac.uk/organisation/ ... id=$org_id")
Last edited by neel_basu on Wed Dec 13, 2006 7:11 am, edited 1 time in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Ok, let's see if I understand this correctly...

A user completes a form, submits the form, the code inserts the data they just entered and returns to the user the ID of the record they just inserted? Is that what you are after?
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

That is exact what I want.

User completes form and inserts the data.

Once Submit is selected the a new form is loaded with a message.

This works so far.

But I also want it to return the org_id next to the message.

The CODE

This file is processed once the user adds data to the form and clicks submit and returns a new blank form..

Code: Select all

Connect to database...........

mysql_select_db("contact_management_system",$link) or die("Could not select database");
 $sql = "INSERT INTO organisations (org_id,person_id, orgname, web_url, notes ) VALUES ('$org_id','$person_id','$orgname','$web_url', '$notes')";
 if ($result = mysql_query($sql,$link)) {
    header ("location:http://www.soi.city.ac.uk/organisation/pl/CMS/Uorgs.html?Sent=true&id=$org_id");
} else {
    die ( mysql_error($link));
}

When the data is processed the code below returns a message to the user

Code: Select all

<?php
if ((isset($_GET['Sent'])) and ($_GET['Sent'] == 'true')) { echo '<b><font color="#FF0000">New Organisation Added, Add Another? Remember to Search for the Organisation and note the OID before Adding the Person Linked to the created Organisation</font></b>Your org id is'.$_GET[id]; }
?>
Note I have made changes to the last lines of both sets of code according to the advice given by neel_basu to view the original code look at the first post.

Any help would be much appreciated.


Regards
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

neel_basu wrote:Save The Page Where The
<?php
if ((isset($_GET['Sent'])) and ($_GET['Sent'] == 'true')) { echo '<b><font color="#FF0000">New Organisation Added, Add Another? Remember to Search for the Organisation and note the OID before Adding the Person Linked to the created Organisation</font></b>Your org id is'.$_GET[id]; }
?>
Is As some_file_name.php

And Use
header ("location:http://www.soi.city.ac.uk/organisation/ ... id=$org_id")
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

I dont understand the point of doing this, its the same prinicple isnt it???

The page is already saved and all it returns is the original message plus "Your org_id"

But doest display the org ID
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

Oh I see why you suggest using the extention .PHP

This does not matter, our server parses html files as PHP (so long as it has PHP script) we dont have to save files as .php

Can someone please provide help with this query.

Everah, I replied to your question in the above post.. Any Suggestions?
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

:lol: I Just Told It To Know It Confirmly To Make Sure About It Cause Your Code Runs Well In My PC
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

so what should I do now?
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

So what should I do now???
Post Reply