Search the Community
Showing results for tags 'php html button'.
-
Ok here it goes guys let me explain what I want to do. I am writing a PHP script built into a HTML file. The page will have a series of tables. The fist table will have be were the user inputs the required information to connect to there mysql database. at the bottom of the table will be a button with the onclick action set to call my php script to connect to the data base. Once connected I want data saying connected successfully or the error messges put into the table data fields marked in red below. Button is in blue. do I put the php script with in the <td> I want the respose to? Making sure it echo's the html tags needed? <tr><td align="right">Database host: </td><td> <input type="text" name="host"/></td></tr> <tr><td align="right">Database name:</td><td> <input type="text" name="dbname"/></tr> <tr><td align="right">Username:</td><td><input type="text" name="username"/></td></tr> <tr><td align="right">Password:</td><td><input type="password" name="password"/></td></tr> <tr><td>out put from the php script that connects to the database and makes sure its connected to the right database</TD</tr> <tr><td><button ---- to call the php function to connect to the data base/></td></tr> This is the code I have now but I'm not sure if this will work. I'm not sure how to reference the data in the input fields, to the peramiters passed to the function. Can someone shed some light?? Thanks <div id="database"> <table border = "1" align="center" cellpadding="10"> <tr> <td align="right">Zen-Cart Database Name:</td><td><input type="text" name="dname" /></td><td align="right" >Database Table Prefix(no spaces):</td><td><input type="text" name="prefix"/></td> </tr> <tr> <td align="Right">Database Username:</td> <td><input type="text" name="Uname"/></td> <td align="right">Password:</td> <td><input type="password" name="pass"/></td> </tr> <tr> <td align="right">Database host:</td><td><input type="text" name="host"/></td> <tr> <?php Function dbconect($host,$dbname,$Un,$pass,) { mysql_connect($host,$Un,$pass) or die (my_err()); echo("<td>Connected to your mysql database!</td>"); mysql_select_db($dbname) or die (mysql_error()); echo('<td>Connected to My Sql database name ' . $dbname . '</td>); } ?> </tr> <tr><td> </td><td colspan="2"><button type="button onclick="dbconnect(host,dname,Uname,pass)">Test Connection</button></td></tr> </table> </div>