Jump to content

Recommended Posts

<?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

 

Link to comment
https://forums.phpfreaks.com/topic/70456-no-php-respond-to-my-buttons/
Share on other sites

<?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

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

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.

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..



<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..

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.