MySQL interesse |
|
hooii,
Ik heb van de scripts hier een script gebruikt waarmee je een een code moet invullen voordat je kan submitten!.
opzich werkt dit wel!. maar hij onthoudt de gegevens niet die in de db geplaats moeten worden.. ik snap dr van waarom hij dat niet doet..
hier het script. hoop dat iemand me helpen kan
<?
session_start();
?>
<table width=700 cellpadding=0 cellspacing=0 border=0 height=100%>
<tr>
<td width=480 valign=top align=center>
<?PHP
function form_val($url, $chars = false, $this_chars = false){
if($chars == false || !is_numeric($chars)){
$chars = 3;
}
if($this_chars == false || !is_array($this_chars)){
$this_chars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
);
}
if($chars == false || !is_numeric($chars)){
$chars = 3;
}
if(empty($_SESSION['validate_code'])){
$save = '';
for($for = 0; $for < $chars; $for++){
$save .= $this_chars[mt_rand(0, (count($this_chars)-1))];
}
$_SESSION['validate_code'] = $save;
}
// invul velden!!!
echo "<a name=plaats>";
echo "<table width=95% cellpadding=0 cellspacing=0 border=0 style=\"BORDER: rgb(192,192,192) 1px solid;\">";
echo "<tr>";
echo "<td align=center style=\"BORDER-BOTTOM: rgb(192,192,192) 1px solid;\" bgcolor=#C0C0C0 colspan=2>";
echo "<b>Bericht toevoegen</b>";
echo "</td>";
echo "</tr>";
echo "<form method=POST name=form1 action=?p=extras/plaats1>";
echo "<tr>";
echo "<td> <img src=layout/arrow1.gif> Naam:</td><td><input type=text name=naam size=30 value=".$_POST['naam'].">";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td> <img src=layout/arrow1.gif> Homepage:</td><td><input type=text name=homepage size=30 value=http://".$_POST['email'].">";
echo "</td>";
echo "<tr>";
echo "<td> <img src=layout/arrow1.gif> Emailadres:</td><td><input type=text name=email size=30 value=".$_POST['email'].">";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td> <img src=layout/arrow1.gif> Bericht:</td><td><textarea name=bericht rows=5 cols=50>".$_POST['bericht']."</textarea>";
echo "</td>";
echo "</tr>";
echo "</tr>";
echo "<tr>";
echo "<td> <img src=layout/arrow1.gif> Validatie:</td><td>><input type=\"text\" name=\"val\"> <img src=\"validate.php\" />";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=2 align=center height=30 valign=middle style=\"BORDER-TOP: rgb(192,192,192) 1px solid;\"><input type=submit name=valid value=Toevoegen> <input type=reset name=reset value=Reset></td>";
echo "</tr>";
echo "</table></form>";
if(isset($_POST['valid'])){
if($_POST['val'] == $_SESSION['validate_code']){
$_SESSION['validate_code'] = '';
header('Location: '.$url);
}
else{
echo 'De code klopt niet!';
}
}
}
if($_GET['act'] == 'Yep'){
$dag = date("d-m-Y");
$tijd = date("H:i:s");
$klok = "$dag om $tijd";
$sql = "INSERT INTO gastenboek (naam, datum, homepage, email, bericht) VALUES ('".$_POST['naam']."', '$klok', '".$_POST['homepage']."', '".$_POST['email']."', '".$_POST['bericht']."')";
mysql_query($sql) or die (mysql_error());
echo "<br>";
echo "<table width=98% cellpadding=0 cellspacing=0 border=0 style=\"BORDER: rgb(192,192,192) 1px solid;\">";
echo "<tr><td align=center style=\"BORDER-BOTTOM: rgb(192,192,192) 1px solid;\" bgcolor=#C0C0C0><b>Bericht toegevoegd</b></td></tr>";
echo "<tr><td align=center>";
echo "Bedankt voor je bericht, Je wordt teruggestuurd";
echo "<meta http-equiv=\"refresh\" content=\"2\"; url=\"?p=extras/gastenboek\">";
echo "</td></tr>";
echo "</table>";
}
else{
echo form_val('?p=extras/plaats1&act=Yep');
}
?>
<? ?> <table width=700 cellpadding=0 cellspacing=0 border=0 height=100%> <tr> <td width=480 valign=top align=center> <?PHP function form_val($url, $chars = false, $this_chars = false){ $chars = 3; } if($this_chars == false || !is_array($this_chars)){ $this_chars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ); } $chars = 3; } if(empty($_SESSION['validate_code'])){ $save = ''; for($for = 0; $for < $chars; $for++){ } $_SESSION['validate_code'] = $save; } // invul velden!!! echo "<table width=95% cellpadding=0 cellspacing=0 border=0 style=\"BORDER: rgb(192,192,192) 1px solid;\">"; echo "<td align=center style=\"BORDER-BOTTOM: rgb(192,192,192) 1px solid;\" bgcolor=#C0C0C0 colspan=2>"; echo "<b>Bericht toevoegen</b>"; echo "<form method=POST name=form1 action=?p=extras/plaats1>"; echo "<td> <img src=layout/arrow1.gif> Naam:</td><td><input type=text name=naam size=30 value=".$_POST['naam'].">"; echo "<td> <img src=layout/arrow1.gif> Homepage:</td><td><input type=text name=homepage size=30 value=http://".$_POST['email'].">"; echo "<td> <img src=layout/arrow1.gif> Emailadres:</td><td><input type=text name=email size=30 value=".$_POST['email'].">"; echo "<td> <img src=layout/arrow1.gif> Bericht:</td><td><textarea name=bericht rows=5 cols=50>".$_POST['bericht']."</textarea>"; echo "<td> <img src=layout/arrow1.gif> Validatie:</td><td>><input type=\"text\" name=\"val\"> <img src=\"validate.php\" />"; echo "<td colspan=2 align=center height=30 valign=middle style=\"BORDER-TOP: rgb(192,192,192) 1px solid;\"><input type=submit name=valid value=Toevoegen> <input type=reset name=reset value=Reset></td>"; if(isset($_POST['valid'])){ if($_POST['val'] == $_SESSION['validate_code']){ $_SESSION['validate_code'] = ''; } else{ echo 'De code klopt niet!'; } } } if($_GET['act'] == 'Yep'){ $klok = "$dag om $tijd"; $sql = "INSERT INTO gastenboek (naam, datum, homepage, email, bericht) VALUES ('".$_POST['naam']."', '$klok', '".$_POST['homepage']."', '".$_POST['email']."', '".$_POST['bericht']."')"; echo "<table width=98% cellpadding=0 cellspacing=0 border=0 style=\"BORDER: rgb(192,192,192) 1px solid;\">"; echo "<tr><td align=center style=\"BORDER-BOTTOM: rgb(192,192,192) 1px solid;\" bgcolor=#C0C0C0><b>Bericht toegevoegd</b></td></tr>"; echo "<tr><td align=center>"; echo "Bedankt voor je bericht, Je wordt teruggestuurd"; echo "<meta http-equiv=\"refresh\" content=\"2\"; url=\"?p=extras/gastenboek\">"; } else{ echo form_val ('?p=extras/plaats1&act=Yep'); } ?>
|