zgkhoo Posted September 24, 2007 Share Posted September 24, 2007 <?php include 'config.php'; if(isset($_REQUEST['createDB'])){ include 'createdb.php'; } include 'opendb.php'; if(isset($_REQUEST['cPerson'])){ echo "cperson"; $sql = "CREATE TABLE person ( Username varchar(13) )"; mysql_query($sql,$con); } ?> <html> <body> </br> </br> </br> <center> <h1> Sports Toto </h1> <img src="toto.gif"> <form action="index.php" method="POST"> <h2>Username <input type="text" name="username"/> <br/> Password <input type="password" name="password"/> </h2> <input type="submit" value="Log In"> </form> </center> <button name="createDB">Create DB</button> <button name="cPerson">Create person table</button> <button name="cTrans">Create transaction table</button> <button name="cResult">Create result table</button> </body> </html> when i clicked the two button, it wont create db and table, why? thannks Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/ Share on other sites More sharing options...
HuggieBear Posted September 24, 2007 Share Posted September 24, 2007 Try changing this: mysql_query($sql,$con); to this: mysql_query($sql, $con) or die("Can't execute sql" . mysql_error()); Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353967 Share on other sites More sharing options...
zgkhoo Posted September 24, 2007 Author Share Posted September 24, 2007 after change also same. Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353972 Share on other sites More sharing options...
HuggieBear Posted September 24, 2007 Share Posted September 24, 2007 Try putting the buttons inside the <form> tag, and also change them to submit input types. Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353979 Share on other sites More sharing options...
zgkhoo Posted September 24, 2007 Author Share Posted September 24, 2007 <?php include 'config.php'; if(isset($_REQUEST['createDB'])){ include 'createdb.php'; echo "testing"; } include 'opendb.php'; if(isset($_REQUEST['cPerson'])){ echo "cperson"; $sql = "CREATE TABLE person ( Username varchar(13) )"; mysql_query($sql, $con) or die("Can't execute sql" . mysql_error()); } ?> <html> <body> </br> </br> </br> <center> <h1> Sports Toto </h1> <img src="toto.gif"> <form action="index.php" method="POST"> <h2>Username <input type="text" name="username"/> <br/> Password <input type="password" name="password"/> </h2> <input type="submit" value="Log In"> <input type="submit" name="CreateDB" value="create db"> </form> </center> <!--<button name="createDB">Create DB</button>--> <button name="cPerson">Create person table</button> <button name="cTrans">Create transaction table</button> <button name="cResult">Create result table</button> </body> </html> changed to above , also same problem wont display the echo "testing"; at all after click the button Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353982 Share on other sites More sharing options...
HuggieBear Posted September 24, 2007 Share Posted September 24, 2007 php is case sensitive, so you'd need to change this <input type="submit" name="CreateDB" value="create db"> to this <input type="submit" name="createDB" value="create db"> Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353983 Share on other sites More sharing options...
zgkhoo Posted September 24, 2007 Author Share Posted September 24, 2007 thanks ...it work, but y must type="submit" and included inside form? php cant interact with <button> tag? Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353984 Share on other sites More sharing options...
HuggieBear Posted September 24, 2007 Share Posted September 24, 2007 You can still use the button tag, but just make sure it's inside the form tag. Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353987 Share on other sites More sharing options...
cooldude832 Posted September 24, 2007 Share Posted September 24, 2007 I'm just wondering whats your purpose of dynamic table construction. This is considered a no no in mysql/php unless you have a valid reason to do so. Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353988 Share on other sites More sharing options...
zgkhoo Posted September 24, 2007 Author Share Posted September 24, 2007 dynamic table construction??? wats that? Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353990 Share on other sites More sharing options...
HuggieBear Posted September 24, 2007 Share Posted September 24, 2007 Cooldude means creating a database table by clicking buttons in php rather than in mysql directly. I wasn't aware that this was a faux pas in PHP and would imagine that it's something to do with security, but this should be no more insecure than doing it in mysql directly so long as you put the appropriate measures in place. Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353995 Share on other sites More sharing options...
cooldude832 Posted September 24, 2007 Share Posted September 24, 2007 No i thought this was a public area script where more tables coudl be made. To tell you the truth either way its a no, because you never need more to create more than a few tables, and if you need a lot of tables then something is wrong, because your storing method is flawed. Write otu the point of all the tables. Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353997 Share on other sites More sharing options...
zgkhoo Posted September 24, 2007 Author Share Posted September 24, 2007 oh i just testing...so just include create table script outside...later will be make it inside others pages. if(isset($_REQUEST['createDB'])){ include 'createdb.php'; echo "testing"; } but why loading this page then create the db? y not after i click the create DB only create the db? weird.. Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-353998 Share on other sites More sharing options...
zgkhoo Posted September 24, 2007 Author Share Posted September 24, 2007 it will display the "testing" when loading not after i clicked the button anyone know where goes wrong? thanks. Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-354010 Share on other sites More sharing options...
d22552000 Posted September 24, 2007 Share Posted September 24, 2007 idk but change lal your $_REQUESTS to $_POST cause your using post to submit the form.. request includes teh browsers info and can screw up a script if someone hacks their browser info . Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-354021 Share on other sites More sharing options...
zgkhoo Posted September 25, 2007 Author Share Posted September 25, 2007 <html> <body> </br> </br> </br> <center> <h1> Sports Toto </h1> <img src="toto.gif"> <form action="index.php" method="POST"> <h2>Username <input type="text" name="username"/> <br/> Password <input type="password" name="password"/> </h2> <input type="submit" value="Log In"> <input type="submit" name="createDB" value="createDB"> </form> </center> <button name="cPerson">Create person table</button> <button name="cTrans">Create transaction table</button> <button name="cResult">Create result table</button> </body> </html> <?php include 'config.php'; if(isset($_POST['createDB'])){ include 'createdb.php'; echo "testing"; } include 'opendb.php'; if(isset($_REQUEST['cPerson'])){ echo "cperson"; $sql = "CREATE TABLE person ( Username varchar(13) )"; mysql_query($sql, $con) or die("Can't execute sql" . mysql_error()); } ?> latest modified code, still the same, will display "testing" and create the db when load, not perform those action when click the button which i intend to do... anyone know where is the problem? thanks.. Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-354675 Share on other sites More sharing options...
zgkhoo Posted September 25, 2007 Author Share Posted September 25, 2007 work already...but y must include button inside the form? Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-354686 Share on other sites More sharing options...
HuggieBear Posted September 25, 2007 Share Posted September 25, 2007 Because that's the way that valid html works. Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/#findComment-354759 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.