Actually having it add something into database
Posted: Thu Jan 22, 2004 9:11 am
Some of you might already have seen this form however it got it loads up without errors.
after deciding to clean it up
However it does not add anything in to the database. infact i got 3 questions.
1: are php functions private by default, since it would reconize the ".$tablename." in the INSERT INTO line.
2: how can i actually have form input being added into the database.
3. how can i make this page return automaticly to the form again.
However it does not add anything in to the database. infact i got 3 questions.
1: are php functions private by default, since it would reconize the ".$tablename." in the INSERT INTO line.
2: how can i actually have form input being added into the database.
3. how can i make this page return automaticly to the form again.
Code: Select all
<?
require ("include/styles.php"); //css
require ("include/db.php"); //database
/* variable url pagina local */
if (isset($_POST['stage']) &&('process' == $_POST['stage'])) {
process_form();
} else {
print_form();
}
// impri
function print_form() {
echo <<<END
<head>
<body>
<table border="0" cellpadding="0" cellspacing="0" bordercolor="#111111" width="600" height="450">
<tr>
<td width="100%" height="450">
<div align="center" style="width: 555; height: 282">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="614" height="280">
<tr>
<td width="283" height="320" class="e" class="r">
<form action="$_SERVER[PHP_SELF]" method="post" class="e">
Empresa<font size=8><input type=text name="Empresa"></input><br>
<input type="hidden" name="stage" value="process">
</font>Codigo<font size=8><input type=text name="Codigo"></input><br>
<input type="hidden" name="stage" value="process">
</font>Desde<font size=8><input type=text name="Desde"></input><br>
<input type="hidden" name="stage" value="process">
</font>envio<font size=8><input type=text name="Envio"></input><br>
<input type="hidden" name="stage" value="process">
</font>Informacion<font size=8><input type=text name="Information"></input><br>
<input type="hidden" name="stage" value="process">
</font>Comentario<font size=8><textarea name="Comentario" rows="4" cols="20" size="18"></textarea><br>
<input type="hidden" name="stage" value="process">
<p>
<br>
<p></td>
<td width="328" height="211" class="e" align="right">
<class="e">
Peso Total<font size=8><input type=text name="Peso_Total" size="10"></input></font><br>
Peso<font size=8><input type=text name="Peso" size="10"></input></font><p>
Valor<font size=8><input type=text name="Valor" size="16"></input></font>
<p>
<br>
<Div class="r"><input name="submit" type="submit" ID="Avancar" WIDTH="5" CLASSID="CLSID:B6FC3A14-F837-11D0-9CC8-006008058731">
</div>
</form>
END;
}
/* conectarse con el base datos a entro db.php, aqui solo ponerlo el informacion */
function process_form() {
$query ="INSERT INTO pongo VALUES ('".$_POST['Empresa']."','".$_POST['Codigo']."','".$_POST['Desde']."','".$_POST['Envio']."','".$_POST['Information']."','".$_POST['Comentario']."','".$_POST['Peso_Total']."','".$_POST['Peso']."','".$_POST['Valor']."')";
if (!$result = mysql_query($query))";
die ( .mysql_error())";
}
?>