Myles Web Design

Myles Web Design
13G Forest Park Road
Dundee
DD1 5NZ
Mobile: 07859067107
Sales@MylesWebDesign.co.uk
Website was Born on 7th August 2010, last evolved 16th May 2012
<form action="comment_box.php" method="post">
Name &nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="MWDname" /><br />
Message <input type="text" name="MWDmessage" /><br />
<input type="submit" />
</form>

<?php
$MWDsqlserver = "yourmysqlservername_probably_localhost";
$MWDsqluserid = "yourusername";
$MWDsqlpassword = "yourpassword";
$MWDsqldatabase = "yourdatabase";

if(!($MWDCon = mysqli_connect($MWDsqlserver, $MWDsqluserid, $MWDsqlpassword)
or die(mysql_error()))) { printf("Errormessage: %s\n", mysqli_error($MWDCon)); } if(!(mysqli_select_db($MWDCon,$MWDsqldatabase) or die(mysql_error()))) { printf("Errormessage: %s\n", mysqli_error($MWDCon)); } // Create a MySQL table in the selected database if(!(mysqli_query($MWDCon,"CREATE TABLE IF NOT EXISTS MWDTbComments( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), MWDname VARCHAR(30), MWDmessage VARCHAR(200))")or die(mysql_error()))) { printf("Errormessage: %s\n", mysqli_error($MWDCon)); } if(!(mysqli_query($MWDCon,"INSERT INTO MWDTbComments (MWDname, MWDmessage)
VALUES('$_POST[MWDname]', '$_POST[MWDmessage]' ) "
)or die(mysql_error()))) { printf("Errormessage: %s\n", mysqli_error($MWDCon)); } if(!($result = mysqli_query($MWDCon,"SELECT * FROM MWDTbComments"))) { printf("Errormessage: %s\n", mysqli_error($MWDCon)); } while($row = mysqli_fetch_array($result)) { echo "<br />
"; echo $row['MWDname']; echo "<br /> " ; echo $row['MWDmessage']; echo "<br />"; } mysqli_free_result($result); mysqli_close($MWDCon); ?>









Author:
Bruce Myles, Dundee Web Designer
2012-04-30T20:50:16+01:00


timestamp added to messages


Author:
elias


fantastik


Author:
Bruce Myles, Dundee Web Design


Hi Dave, I presume you mean a CAPTCHA challenge-response test. Well I have written a quick bit of code which does the job. I will need to get it to randomly select a picture from a list. At the moment there is just the one picture and the code just checks the input text to see does it match. Ideally I would need a computer to generate the pictures. But one step at a time. I will get the code for what I have done on the site soon.


Author:
Dave


can you add code for me, so the comments are not posted un less some code is entered which its displayed on a picture.


Author:
Nokia x6


Does this work with my phone,YES!


Author:
Bruce Myles


Also the code above doesn't check to see if the two fields are blank.


Author:
Bruce Myles


This comment box does not use the exact code above. The above code is vulnerable to SQL injection attacks.

  MylesWebDesign.co.uk   ©2010