java - How do you send info from html to sql -
so trying fill out customer info, send customer info sql database table. have database made know right values going it. dont know how in. have posted code customer screen.
<html> <head> <title>customer info</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> table, td { border: 5px blue; } </style> <script type="text/javascript" src=validator.js></script> <link rel="previous" href="index.html"> </head> <body> <h1 style="text-align:center;color:steelblue"> customer info </h1> <h5 id="errormessage" style="text-align:center;color:red"></h5> <form action=customerinfo.html method="post" onsubmit="return validatecustomerform(this)"> <table style="margin-right:auto;margin-left:auto"> <tr> <td style="text-align:right">first name:</td> <td><input type="text" name="firstname" size="30"/></td> </tr> <tr> <td style="text-align:right">last name:</td> <td><input type="text" name="lastname" size="30"/></td> </tr> <tr> <td style="text-align:right">address:</td> <td><input type="text" name="address" size="50"/></td> </tr> <tr> <td style="text-align:right">city:</td> <td><input type="text" name="city" size="30"/></td> </tr> <tr> <td style="text-align:right">province</td> <td> <select name="provinces"> <option>[select province]</option> <option>ab</option> <option>bc</option> <option>mb</option> <option>nb</option> <option>nl</option> <option>ns</option> <option>nt</option> <option>nu</option> <option>on</option> <option>pe</option> <option>qc</option> <option>sk</option> <option>yt</option> </select> </td> </tr> <tr> <td style="text-align:right">postal code:</td> <td><input type="text" name="postalcode" size="7"/></td> </tr> <tr> <td style="text-align:right">telephone#:</td> <td><input type="text" name="telephone#" size="12"/></td> </tr> <tr> <td colspan='2' style='text-align:center'> <input type='submit' value='submit'/> </td> </tr> </table> </form> </body>
you need server-side language php. have read php, , how can connect php database, e.g mysql.
you need change html form action php file, e.g
<form action="yourphpfile.php" method="post" onsubmit="return validatecustomerform(this)">
a simple example can start with:
<?php $firstname = $_post[firstname]; $lastname = $_post[lastname]; . . // commands open connection database // commands insert database (query) // close database connection . . . ?>
notes:
- $firstname variable , in php variables must begin $ symbol
- $_post used information provided user via html file gave. $_post because use method post in html form, there 1 way , method.
below, introduction links can start:
just go through mysql database
section @ website provided.
Comments
Post a Comment