Page 1 of 4

Printing some results on screen when submit is selected

Posted: Tue Dec 12, 2006 9:40 am
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

Posted: Tue Dec 12, 2006 10:12 am
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

Posted: Tue Dec 12, 2006 10:27 am
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

Posted: Tue Dec 12, 2006 10:38 am
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]; } 
?>

Posted: Tue Dec 12, 2006 10:46 am
by mohson
This time it prints
Your org id is
Why is it not printing the org_id that was just updated?

Posted: Tue Dec 12, 2006 11:21 am
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

Posted: Tue Dec 12, 2006 11:24 am
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")

Posted: Tue Dec 12, 2006 7:11 pm
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?

Posted: Wed Dec 13, 2006 3:52 am
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

Posted: Wed Dec 13, 2006 7:12 am
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")

Posted: Wed Dec 13, 2006 9:39 am
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

Posted: Wed Dec 13, 2006 9:46 am
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?

Posted: Wed Dec 13, 2006 9:49 am
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

Posted: Wed Dec 13, 2006 9:56 am
by mohson
so what should I do now?

Posted: Wed Dec 13, 2006 9:59 am
by mohson
So what should I do now???