Hér eru skjölin:
senda.php
<?php if ( 4 * $_POST["challenge"] == $_POST["solution"] ){ include "connect.php"; if(isset($_POST['submit'])) { $name=$_POST['name']; $country=$_POST['email']; $website=$_POST['website']; $comment=$_POST['comment']; if(strlen($name)<1) { print "Þú skrifaðir ekki inn nafnið þitt, reyndu aftur"; } else if(strlen($comment)<1) { print "Þú skrifaðir ekki athugasemd, reyndu aftur"; } else { $insert="Insert into visitordata (name,email,website,comment,time,date) values('$name','$email','$website','$comment','$time','$date')"; mysql_query($insert) or die("Færsla mistókst, reyndu aftur"); ob_start(); echo "Test"; header("Location: http://www.ljosmyndarinn.com/gestabok"); ob_flush(); } } } else { print "Vitlaus útreikningur" } ?>
Skrifa.php
<form action='senda.php' method='post'> Nafn: <input type='text' name='name' size='20'><br/><br/> Netfang: <input type='text' name='email' size='20'><br/><br/> Vefsíða: <input type='text' name='website' size='20'><br/><br/> <?php $random1 = rand(1,10); $random2 = rand(1,10); echo "Hvað eru " . $random1 . " plús " .$random2 . ": "; echo "<input type=\"text\" name=\"challenge\">"; echo "<input type=\"hidden\" name=\"solution\" value=\"" . 4 * ($random1 + $random2) . "\">"; ?> <br/> Skilaboð:<br/><br/> <textarea name='comment' rows='5' cols='40'></textarea><br/><br/> <input type="submit" name="submit" value="Senda"></form><br/><br/>
Lesa.php
<?php include "connect.php"; $getdata="SELECT * from visitordata order by entryID desc"; $getdata2=mysql_query($getdata) or die("Could not get data"); while($getdata3=mysql_fetch_array($getdata2)) { $getdata3[name]=strip_tags($getdata3[name]); $getdata3[email]=strip_tags($getdata3[country]); $getdata3[website]=strip_tags($getdata3[website]); $getdata3[comment]=strip_tags($getdata3[comment]); print "<h3>$getdata3[name] </h3>"; print "<i>$getdata3[website]</i><br>"; print "<br>"; print "$getdata3[comment]<br><br><br>"; } ?>
Takk fyrir.
Don't eat yellowsn0w!