a real INSERT INTO (mysql) with queryResult SAME PAGE
Posted: Tue Dec 23, 2003 3:11 pm
well,
for a newbie like me it s really strange see around a lot of different codes targeting to the same direction. oh! sorry...should it be...but too many people seems not to care about the others and write codes that or make nonsense or it s not a right code to study with...and this "newbie" poor boy spent a lot of time surfing around...
i would like with this with the complement of other guys really develop a page with a REAL SENSE direction so other users could make part and share with others as well.
so i will begin the first line :
// this code it s intending to INSERT data into a MYSQL database
// this database have the following fields
// -> id (autoincrement)
// -> name
// -> e-mail
// one important point to consider is : i would like to implement just one page to INSERT and after INSERTED (making use of $SERVER_PHPSELF;) // we could have LISTED the INSERTED ITEMS at the same PAGE !!!
// FIRST PART OF THE CODE : DEVELOP THE FORM - EVERYTHING INSIDE //THE CODE
// THE PAGE IS : INSERT_AND_SEE.PHP
//
/* ////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\ */
// if the block below does not make sense - please correct
echo "<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">";
echo "<table border=\"1\" cellspacing=\"0\" cellapadding=\"0\" align=\"center\">";
echo "<tr><td>Nome</td><td><input type=\"text\" size=\"30\"></td></tr>";
echo "<tr><td>E-mail</td><td><input type=\"text\" size\"30\"></td></tr>";
echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Send This Form\"></td></tr> ";
echo "</table>";
echo "</form>";
$db_host="localhost"; // or the host you use
$db_user="you:username";
$db_pass="your:database:password";
$db_bank="your:database:name";
// connecting to the server
$db_link = mysql_pconnect($db_host, $db_user, $db_pass) or trigger_error(mysql_error(),E_USER_ERROR);
$db_select = mysql_select_db($db_bank, $db_link);
// i will stop here ... if someone have more important points to add, please // do it JUST KEEP IN TOUCH TO COPY THE PART OF THE CODE : AND //CONTINUE RIGHT FROM THE LAST STEP[/b]
-> this comments JUST TRY TO STOP AND SOLVE a CONFUSION / or FAILURE OF COMMUNICATION and this piece of comments regards the ones BELOW by : Gen-ik - thomasd1 - Bill H
guys :
--------------------------------------------------------------------
1. I did not say people that share their time to help others develop CRAP CODE...
2. My answer to mr. GEN it was not sarcastic but my point of view to answer his comments. Nothing at all...
3. About the confusion for some different codes u probably be right...but there“s differences for what is and should be.
I just intended to the code above, only to serve as reference and numbered a very simple drive code like :
-> the schema :
-----------------------------------------------
1. display a page with a form to insert records to a database.
2. The FORM must use in ACTION = "$SERVER['PHPSELF']; . so it will loop back parsing two actions:
::: 2. 1 -> inserting the form "elements" to the bank and must DISPLAY the INSERTED ITEM only identify by ID ( I think must be the right option - but I am not sure) .
::: 2. 2 -> This method is very common when you are registering on a site and when performing the form it returns the informations you send to the server. the difference is that i would like to see everything into one single page executing this actions.
I only want to develop an schema very simple that could help others as me either....but...i did not think this could bring confusion and no solution for what I intended in the begining.
Bye,
Poeta_Eletrico
for a newbie like me it s really strange see around a lot of different codes targeting to the same direction. oh! sorry...should it be...but too many people seems not to care about the others and write codes that or make nonsense or it s not a right code to study with...and this "newbie" poor boy spent a lot of time surfing around...
i would like with this with the complement of other guys really develop a page with a REAL SENSE direction so other users could make part and share with others as well.
so i will begin the first line :
// this code it s intending to INSERT data into a MYSQL database
// this database have the following fields
// -> id (autoincrement)
// -> name
// one important point to consider is : i would like to implement just one page to INSERT and after INSERTED (making use of $SERVER_PHPSELF;) // we could have LISTED the INSERTED ITEMS at the same PAGE !!!
// FIRST PART OF THE CODE : DEVELOP THE FORM - EVERYTHING INSIDE //THE CODE
// THE PAGE IS : INSERT_AND_SEE.PHP
//
/* ////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\ */
// if the block below does not make sense - please correct
echo "<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">";
echo "<table border=\"1\" cellspacing=\"0\" cellapadding=\"0\" align=\"center\">";
echo "<tr><td>Nome</td><td><input type=\"text\" size=\"30\"></td></tr>";
echo "<tr><td>E-mail</td><td><input type=\"text\" size\"30\"></td></tr>";
echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Send This Form\"></td></tr> ";
echo "</table>";
echo "</form>";
$db_host="localhost"; // or the host you use
$db_user="you:username";
$db_pass="your:database:password";
$db_bank="your:database:name";
// connecting to the server
$db_link = mysql_pconnect($db_host, $db_user, $db_pass) or trigger_error(mysql_error(),E_USER_ERROR);
$db_select = mysql_select_db($db_bank, $db_link);
// i will stop here ... if someone have more important points to add, please // do it JUST KEEP IN TOUCH TO COPY THE PART OF THE CODE : AND //CONTINUE RIGHT FROM THE LAST STEP[/b]
-> this comments JUST TRY TO STOP AND SOLVE a CONFUSION / or FAILURE OF COMMUNICATION and this piece of comments regards the ones BELOW by : Gen-ik - thomasd1 - Bill H
guys :
--------------------------------------------------------------------
1. I did not say people that share their time to help others develop CRAP CODE...
2. My answer to mr. GEN it was not sarcastic but my point of view to answer his comments. Nothing at all...
3. About the confusion for some different codes u probably be right...but there“s differences for what is and should be.
I just intended to the code above, only to serve as reference and numbered a very simple drive code like :
-> the schema :
-----------------------------------------------
1. display a page with a form to insert records to a database.
2. The FORM must use in ACTION = "$SERVER['PHPSELF']; . so it will loop back parsing two actions:
::: 2. 1 -> inserting the form "elements" to the bank and must DISPLAY the INSERTED ITEM only identify by ID ( I think must be the right option - but I am not sure) .
::: 2. 2 -> This method is very common when you are registering on a site and when performing the form it returns the informations you send to the server. the difference is that i would like to see everything into one single page executing this actions.
I only want to develop an schema very simple that could help others as me either....but...i did not think this could bring confusion and no solution for what I intended in the begining.
Bye,
Poeta_Eletrico