Hi i'm trying to make my own review script but am having lots of trouble. I have done all the html and javascript part but i want it so when a user submits a review it adds it to a database and other users can look at the reviews as well. Here is the html/javascript part where users can write a review, <html> <head> <title>New Anime Review</title> <style type='text/css'> body { margin:0; padding:0; background-color: #000000; color: #FFFFFF; font-size: 18; font-weight: bold; text-align: center; } </style> </head> <body> <h1>New Anime Review</h1> <br /><br /><br /> <ul> <li>Remember to put as much detail into your review as possible.</li> <li>Any spam or inappropriate content will not be accepted.</li> <li>All fields are required.</li> </ul> <br /><br /> <script type='text/javascript'> function formValidator(){ // Make quick references to our fields var anime_name = document.getElementById('anime_name'); var anime_authorname = document.getElementById('anime_authorname'); var anime_messagearea = document.getElementById('anime_messagearea'); // Check each input in the order that it appears in the form! if(isAlphabet(anime_name, "Please enter a name for the anime")){ if(isAlphanumeric(anime_authorname, "Please enter your username for the review")){ if(isNumeric(anime_messagearea, "Please enter your review")){ return true; } } } return false; } function notEmpty(elem, helperMsg){ if(elem.value.length == 0){ alert(helperMsg); elem.focus(); // set the focus to this input return false; } return true; } function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isAlphabet(elem, helperMsg){ var alphaExp = /^[a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isAlphanumeric(elem, helperMsg){ var alphaExp = /^[0-9a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function lengthRestriction(elem, min, max){ var uInput = elem.value; if(uInput.length >= min && uInput.length <= max){ return true; }else{ alert("Please enter between " +min+ " and " +max+ " characters"); elem.focus(); return false; } } </script> <form onsubmit='return formValidator()' method="post" action="a_review.php" > Name Of Anime: <input type='text' id='anime_name' /><br /><br /> Review Author: <input type='text' id='anime_authorname' /><br /><br /> Review: <br /><textarea name="anime_messagearea" rows="12" cols="44"></textarea> <br /><br /><br /> <input type='submit' value='Submit' /> </form> </body> </html> Code (markup): When the user clicks on Submit it takes them to a php page called a_review.php i'm a noob though at php so i'm not sure how i would do all this so it submits to a database and other users can read reviews as well. Any help would be greatly appreciated.
Thanks for replying. I currently don't have any code in the a_review.php file i'm not sure how to code the rest.
basically you want us to make the code for you as well as build a structured database for storing the information?
You don't have to but if you could tell me how i would get it started, maybe even show me some tutorials that would be much appreciated.
<?php //mysql database connection $con = mysql_connect("localhost","DB_USERNAME","DB_PASSWORD"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DB_NAME_HERE", $con); //pull posted data $name = $_POST['name']; $anime_authorname = $_POST['anime_authorname']; $messagearea = $_POST['messagearea']; //verify name is not empty if so error if($name == ''){ //show error here echo "You must provide your name"; exit(); } //verify anime_authorname is not empty if so error if($anime_authorname == ''){ //show error here echo "You must provide an author name"; exit(); } //verify messagearea is not empty if so error if($messagearea == ''){ //show error here echo "You must provide a review"; exit(); } //if not one of the areas posted is empty proceed with insert to db if($name != '' AND $anime_authorname != '' AND $messagearea !=''){ mysql_query("INSERT INTO reviews (name, anime_authorname, messagearea) VALUES ('$name', '$anime_authorname', '$messagearea')"); echo "Thanks for your review."; mysql_close($con); } ?> PHP: You will need to make the Database tables. and a Database. TJ