Add 1 To $reviewnum When User Clicks Submit?
09-11-2009, 04:45 PM
|
Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 824
Name: Scott
Location: Ontario
|
I've made a flat-file database that stores people's reviews that they've submitted to the site through a form. It's all automated, for example, you write your title, your name, and your review into a form and when you click Submit, a PHP form handler (I made) sends the info into a database. After one submit, the database looks something likes this:
Code:
<div id='contentboxtitle'><h1>Title</h1></div><div id='contentbox'><em>A review by Author</em><br /><br />Review</div>
<div id='contentboxtitle'><h1></h1></div><div id='contentbox'><em>A review by </em><br /><br /></div>
Of course, Title is the title, Author is the author, and A review is the review. Now of course many people will be using this form, so I need a way to keep track of all the entries in a simple click.
I've decided to use an add 1 to $reviewnum when the user clicks Submit.
So every time a user clicks submit, the function adds 1 to a number, starting at 0. so the first review added would be 1, the second would be 2...
So I need a few things;
1: How to add one to the number onSubmit
2: Make it so that the database doesn't add to itself again if the user refreshes the page
3: Have a way so the PHP can recall those numbers, the numbers would look something like (ur1, ur2, ur3...) so when a link it pressed, it tells the PHP to open, say, ur2 in a spot.
My problem is the similar to this person's problem, except I don't want it to make a new page every time, just a new number to call from through a link.
Thanks a lot!!
|
|
|
|
09-12-2009, 03:35 AM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 744
Name: Mattias Nordahl
Location: Sweden
|
I'm not sure I understand, but it sound like you could simply use an ID field in the table where the reviews are stored. Every new review would get a unique id, incresed by one for every new review (the ID field would be a primary key with auto_increment). Then the links to open a specific review would look like "show_review.php?id=12345" and would retreive and display the review with ID '12345'.
To solve your second problem, it would be enough to redirect the user after the review has been added. That is, the page being called to add the review to the database, would call header() to redirect the user to, lets say the page to display the new review, as in
header("Location: show_review.php?id=$reviewID");
where $reviewID is the ID of the newly added review.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
|
|
|
|
09-12-2009, 08:47 AM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 824
Name: Scott
Location: Ontario
|
That is exactly what I want, but I don't know how to add 1 to a number in PHP every time something happens. I've Googled it, but so far I've found nothing...
|
|
|
|
09-12-2009, 04:03 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 744
Name: Mattias Nordahl
Location: Sweden
|
You must have a table in your database that stores the reviews, correct? I'm guessing you're using the fields 'title', 'author' and 'review' or similar. Add a new field called 'id' or 'review_id', which is of type INT (integer), as a primary key with the auto_increment option. This means that every new row you add in the table will have it's id set to the last row's id plus one, automatically.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
|
|
|
|
09-12-2009, 05:17 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 824
Name: Scott
Location: Ontario
|
Wow, thanks!
I'll try that, and let you know when I'm done!

|
|
|
|
09-12-2009, 06:18 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 824
Name: Scott
Location: Ontario
|
Sorry, but how do you do this with a Flat File Database? It's just a plain old .txt file... I don't know how to add stuff like that to it. It's not SQL, either... :O
|
|
|
|
09-12-2009, 08:02 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 118
Name: Brian Collins
|
Code:
<?php
$reviewnum ="1";
$reviewnum ++;
echo"$reviewnum";
?>
Try this
__________________
I hope to build a site with something for every one
Please login or register to view this content. Registration is FREE
|
|
|
|
09-12-2009, 09:28 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 824
Name: Scott
Location: Ontario
|
That works, it outputs 2, but I'm looking for something that remembers what was last put in (in this case, 2) and add to that.
Maybe I could use a database that has the number two in it, and get the script to open that database, read the last line, and add a line at the end of it that is 1 more than the last line, like this:
Code:
open database, read last line, put in php script, add 1 to that number, and add the resulting number to the last line of the database
So the next would be 3, 4, 5...
I'll try that!!
|
|
|
|
09-13-2009, 12:11 AM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 118
Name: Brian Collins
|
It would be easy to to with sql
you just read the value from the sql base then use the code to add one to it the append the data base with the new number
__________________
I hope to build a site with something for every one
Please login or register to view this content. Registration is FREE
Last edited by bmcoll3278; 09-13-2009 at 12:13 AM..
|
|
|
|
09-13-2009, 09:32 AM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 824
Name: Scott
Location: Ontario
|
I've tried that, done without SQL, but I either get some massive number that looks like 126534 or something equally as big, and if I refresh that, I get something like 126534651243!??
|
|
|
|
09-13-2009, 02:43 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 744
Name: Mattias Nordahl
Location: Sweden
|
Are you saying you already tried with a MySQL database and abandoned it for a plain text file? Believe me, if you have the possability to use a MySQL database instead, do it. It is much easier, faster and more secure than it would be with your text file.
Tell us about your problems with the MySQL database instead and we can help you out with that.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
|
|
|
|
09-13-2009, 07:40 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 118
Name: Brian Collins
|
Quote:
Originally Posted by lizciz
Are you saying you already tried with a MySQL database and abandoned it for a plain text file? Believe me, if you have the possability to use a MySQL database instead, do it. It is much easier, faster and more secure than it would be with your text file.
Tell us about your problems with the MySQL database instead and we can help you out with that.
|
Dido sql would be the only way to go for many reasons
__________________
I hope to build a site with something for every one
Please login or register to view this content. Registration is FREE
|
|
|
|
09-14-2009, 04:27 AM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
|
Quote:
Originally Posted by Physicsguy
Now of course many people will be using this form, so I need a way to keep track of all the entries in a simple click.
|
What you really need is a way to count the entries in a single click, but if you want to have the number stored separately, create a separate file which holds the last number and then increment that number (which you later populate your $reviewnum variable with.
Quote:
Originally Posted by Physicsguy
So I need a few things;
1: How to add one to the number onSubmit
|
As indicated above, you can use "++". Here are the ways you can increment a number by 1:
PHP Code:
++$reviewnum; $reviewnum++; $reviewnum += 1; $reviewnum = $reviewnum + 1;
I believe ++$reviewnum is ever so slightly faster.
Quote:
Originally Posted by Physicsguy
2: Make it so that the database doesn't add to itself again if the user refreshes the page
|
A bit trickier, but if you use a header("Location: myurl"); exit(); after updating that directs the user to the current page, then refreshing is mostly prevented from double submissions. NOTE: I said "mostly".
Quote:
Originally Posted by Physicsguy
3: Have a way so the PHP can recall those numbers, the numbers would look something like (ur1, ur2, ur3...) so when a link it pressed, it tells the PHP to open, say, ur2 in a spot.
|
Now we get into the fun of it -- you have 1 number which is independent from the posts, but want a number to be uniquely assigned to each post. This is known as a primary key and is something that databases are trained to do (look up autoincrement). In fact, a database is going to save you lots of problems. Some of them are:
- What if 2 users save a review at the same time? Then, the file will have 2 attempts to write to it at the same time. Either 1 will fail, both will fail, or the file will get corrupted.
- Your file contains formatting so it will take up much more space than if you stored simply the information. Your name has "physics" in it, so let me try an analogy: Let's say you wanted to conduct an experiment with 10 different test scenarios... would you want to analyze the data by looking at a full write up for each test scenario or just compare the data? The latter scenario will make your analysis go much smoother and take much less time. Same deal with databases: separate the dynamic data from the static data to save space, effort, and time. Also, by putting in all of that information you'll make it much harder should you ever want to change the format of replies.
- If you ever need to search, then a flat file will be much less efficient than an indexed-database table.
- The list goes on and on and ... you get the point.
__________________
Jeremy Miller
Please login or register to view this content. Registration is FREE
|
|
|
|
09-14-2009, 05:30 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 824
Name: Scott
Location: Ontario
|
Wow.
Ok, I use Free Hostia to host my site, and Free Hostia comes with databases that are used with PHPMyAdmin. Now, I made my database, but now I have my code to add to the text file, not that database, mailny because it didn't work...? I don't konw why.
I definetly will switch to an SQL database if my site gets bigger, with more people coming to it and submitting reviews, but for now, with (hopefully, even) 1 person submitting something PER MONTH, I think I should be good
BTW I do like physics, but I'm not a physics guru, I just like playing with moving objects is a program called Algodoo.
OK, here's what I have so far:
http://www.pgreviews.com/makeyourreview.php
Just try that, (in the Terms and Agreements Policy page, I know it says "I, $loginusername,..." but just write a review (MAKE YOUR NAME "TESTER", so I know I can delete those (unless the review is good!)) And when you click the Add Review button, you'll get a page that says either "Error" or "Thank You". If it was a thank you, go to
http://www.pgreviews.com/ffdatabase.txt
to see what the database now contains.
You see, the database will contain something like this:
Code:
3gh343 <div id=\'contentboxtitle\'><h1>TITLE OF REVIEW</h1></div><div id=\'contentbox\'><em>A review by AUTHOR OF REVIEW</em><br /><br />THE REVIEW ITSELF</div><div id=\'contentboxtitle\'><h3>Rating: 10/10</h3></div><div id=\'contentbox\'>THE REASON FOR RATING WHAT YOU RATED IT</div>
That's it. Now, I know I don't have a PHP statement to check whether a serial number has already been created, but since they're pretty random, 5 characters of letters and numbers, it should be good :P
I can easliy change it to 10, 15, 20... If you think that would help...
But what I need is a thing to read THAT SERIAL NUMBER, and the contents after it. I already have an idea, so let me get to work and I'll post the results!
Thanks for all your help!
PS I'll give credits here to anybody who helped me! 
Last edited by Physicsguy; 09-14-2009 at 06:26 PM..
|
|
|
|
09-14-2009, 05:57 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
|
- First, I'd say to change your TK policy. Giving thanks shouldn't be to the "winner", but to all those who provided some guidance that was informative or helpful and encourages people to proffer their ideas. If everyone followed the winner/most-helpful policy, then many who are not as skilled/informed/whatever would not try to help, not wanting to compete against those who they perceive as more-qualified, reducing the overall pool of ideas. Even the least educated, least experienced person can come up with a brilliant way of solving a problem.

- I have posted to your form with some test data. You'll see these issues:
- Foreign characters (both Chinese and Spanish) did not display correctly on your code-dump or preview pages.
- I inserted code which was properly handled in the preview pages, but you'll want to determine your preferred means of handling such code.
- HTML entities, such as the euro symbol (€), whether entered directly or by the entity code itself, did not render correctly
- There does not appear to be a delimiter between posts and you allow newlines to be entered. This will mean that searching for a specific review will be challenging. You could search for 5 characters, followed by 2 characters, followed by
<div id='contentboxtitle'><h1>but that is cludgy and not subject to easy modification or maintenance.
Hope that helps.
__________________
Jeremy Miller
Please login or register to view this content. Registration is FREE
|
|
|
|
09-14-2009, 06:39 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 824
Name: Scott
Location: Ontario
|
That does!
In my unuploaded version I have a delimeter (the |) so I'm working on making it find that, but so far... No luck...
How would I do this though:
Quote:
You could search for 5 characters, followed by 2 characters, followed by
<div id='contentboxtitle'><h1>but that is cludgy and not subject to easy modification or maintenance.
|
Because that seems really good! I know it's not easy to change, but I'm not planning on changing it...
Also, as for the Chinese/Spanish symbols, I'm not gonna worry about those because my site is English. Maybe I'll do it after things are working perfectly, but for now I'll stick with the normal characters.
I'm having some trouble with all this though. Can you please take a look at it, I'm having no luck.
This is process.php:
PHP Code:
<?php
$reviewTitle = $_POST["reviewtitle"]; $reviewAuthor = $_POST["authorname"]; $reviewContent = $_POST["reviewcontent"]; $reviewRating = $_POST["reviewrating"]; $ratingReason = $_POST["ratingreason"];
function swd_rand($length = 10, $letters = true, $numbers = true, $case = 'i') { $chars = array(); if ($numbers) { $chars = array_merge($chars, range(48, 57)); }
if ($letters OR !$numbers) { $chars = array_merge($chars, range(65, 90), range(97, 122)); } for ($serialNumString = ''; strlen($serialNumString) < $length; $serialNumString .= chr($chars[array_rand($chars)])); switch ($case) { case 'i': default: return $serialNumString; case 'u': return strtoupper($serialNumString); case 'l': return strtolower($serialNumString); } }
$serialNumString = swd_rand(5);
$serials = Array(); //Loop until the array has 1000 values while(count($serials)<1000){ //Generate a random string and add it to the array $serials[] = swd_rand(5); //Remove duplicates in the array $serials = array_unique($serials); } foreach($serials as $value){ $values .= "('".$value."'),"; } $values = rtrim($values,','); $sql = "INSERT INTO serials (serial) VALUES $values"; mysql_query($sql);
$reviewFull = '<div id="contentboxtitle"><h1>'. $reviewTitle . '</h1></div><div id="contentbox"><em>A review by ' . $reviewAuthor . '</em><br /><br />' . $reviewContent . '</div><div id="contentboxtitle"><h3>Rating: ' . $reviewRating . '</h3></div><div id="contentbox">' . $ratingReason . '</div>';
$reviewFullDB = "$serialNumString | $reviewFull |";
$fp = fopen("ffdatabase.txt","a");
if(!$fp) { echo 'Error: Cannot open file.'; exit; }
echo "$serialNumString";
function BadWordsExist(&$string, $words) { foreach($words as &$word) { if(stripos($string, $word) !== false) { return true; } } return false; } function AuthorisAdmin(&$Admins, $AdminNames) { foreach($AdminNames as &$AdminName) { if(stripos($Admins, $AdminName) !== false) { return true; } } return false; } ////////////////////
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Physicsguy's Reviews - <?php echo ("$reviewTitle"); ?> - Edit/Add Review</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="author" content="Scott Kaye" /> <meta name="description" content="Physicsguy's Reviews - Find tutorials, games, reviews, and even guitar tablature on Physicsguy's Reviews, your site for everything!" /> <meta name="keywords" content="Reviews, Games, Software, Tablature, Guitar, Hero, Rock, Band, Physicsguy, Physicsguy's, Reviews, Physics, Phun, Wii, PS3, Playstation, Nintendo, Linux, Ubuntu, Xmoto, Inkscape, HTML, CSS, Super, Mario, Bros, Theme, Legend, Of, Zelda, Scott, Kaye, Scott Kaye, Cool, Site" /> <link rel="stylesheet" href="physicsguystyle2.css" type="text/css" media="screen" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="lavatheme" href="physicsguystyle.css" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="rocktheme" href="physicsguystyle3.css" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="darkmattertheme" href="physicsguystyle4.css" /> <link rel="shortcut icon" href="http://www.webmaster-talk.com/images/favicon.ico" type="image/x-icon" /> <link rel="icon" href="http://www.webmaster-talk.com/images/favicon.ico" type="image/x-icons" /> <meta name="viewport" content="initial-scale = 1.0" /> <script type="text/javascript" src="getscreen.js"></script> <!--This script should appear below your LINK stylesheet tags -->
<script src="styleswitch.js" type="text/javascript"> /*********************************************** * Style Sheet Switcher v1.1- © Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more ***********************************************/ </script> </head> <body> <div id="container"><div id="banner"></div><div id="wrapper"><div id="main"> <script type="text/javascript"> if (pageWidth() < 400) { document.writeln('<link rel="stylesheet" type="text/css" href="mobilestyle.css" /> <h3>You are browsing Physicsguy\'s Reviews in mobile mode. All of the features are here, nothing has changed, other than the size and functionality of this site! <br /><br /> '); } </script> <script type="text/javascript"> if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { if (document.cookie.indexOf("iphone_redirect=false") == -1) document.writeln('<link rel="stylesheet" type="text/css" href="mobilestyle.css" />'); }</script> <!--Begin main content--> <div style="background: #800000; border: 2px solid #000000; padding: 5px; margin-bottom: 5px;"> <h1>Review Preview</h1> <p><em>This is what your review will look like if you add it to PGReviews. If you like the way it looks, click submit, and if you want to make any changes, click Edit.</em></p> <p>Please keep in mind that if you try to post as any admin, you will receive an alert telling you to change your name in order to submit your review. Also, if you try to post any swearwords, they will be caught and you must remove them in order to submit your review.</p> </div> <?php $trans = array( "<" => "<", ">" => ">", "<" => "<", ">" => ">", "&" => "&", "‘" => "‘ ", "'" => "'", "\n" => "<br /> ", ); echo ("<div id='contentboxtitle'><h1>"); echo strtr("$reviewTitle", $trans); echo ("</h1></div>"); echo ("<div id='contentbox'><em>A review by "); echo strtr("$reviewAuthor", $trans); echo ("</em><br /><br />"); echo strtr("$reviewContent", $trans); echo ("</div><div id='contentboxtitle'><h3>Rating: "); echo strtr("$reviewRating", $trans); echo "</h3></div><div id='contentbox'>"; echo strtr("$ratingReason", $trans); echo "</div>"; ?> <div style="background: #800000; border: 2px solid #000000; padding: 5px; margin-top: 5px;">
<?php
$string = $reviewFull; if (BadWordsExist($string, array("****","****","***","****","dick","*****","vagina","piss","sex"))) { echo " <p>Your review contains censored words. Until you remove these words, your review will not be processed.</p> ";$BadWordsError = 1; } else { echo ""; }
$Admins = $reviewFull; if (AuthorisAdmin($Admins, array("Physicsguy","PGReviews","PG","PGR","Physicsguy's Reviews"))) { echo " <p>The name $reviewAuthor is an Admin. You cannot submit reviews as an Admin. Please change the author of your review.</p> ";$AdminError = 1; } else { echo ""; }
$ErrorCount = $AdminError + $BadWordsError;
if ($ErrorCount <= 0) { echo " <table style='border: 0px solid #000000'><tr><p><b>Congragulations, your review validates! Click 'Add Review' to add your review to PGReviews, or 'Edit' if you do not like the way it turned out.</b></p> <form method='post' action='addReview.php' /> <textarea name='reviewfulladd' readonly='readonly' style='background: transparent; border: none; overflow: hidden; visibility: none; display: none;'>$reviewFullDB</textarea> <textarea name='reviewserialnumber' readonly='readonly' style='background: transparent; border: none; overflow: hidden; visibility: none; display: none;'>$serialNumString</textarea> <textarea name='reviewtrans' readonly='readonly' style='background: transparent; border: none; overflow: hidden; visibility: none; display: none;'>$trans</textarea> <input type='submit' value='Add Review' /> </form> <input type='button' value='Edit' onClick='history.back()' /> </tr></table> "; } else if ($ErrorCount <= 1) { echo "<p><input type='button' value='Edit' onClick='history.back()' /> Found 1 error.</p>"; } else if ($ErrorCount <= 2) { echo "<p><input type='button' value='Edit' onClick='history.back()' /> Found 2 errors.</p>"; } ?> </div>
<!--End main content-->
</div></div><div id="extension">
<!--Begin right side content-->
<?php include("form.html"); ?> <?php include("stylebuttons.htm"); ?>
<h2>Other Links</h12> <hr> <h3><a href="reviews.shtml">Go Back</a></h3> <hr> <a href="index.html">Back To Welcome</a>
<?php include("rightsidemenu.htm"); ?>
<hr />
<a href="setup.shtml">Settings</a>
<!-- End right side content -->
</div><div id="navigation"><div id="navmenu"><ul>
<!-- Begin navigation links...add as necessary -->
<?php include("leftsidemenu.htm"); ?>
<!-- End navigation links -->
</ul></div></div>
<div id="footer"><p class="footspace">© 2009 Physicsguy | <a href="setup.shtml">Settings</a></p></div></div> </body> </html>
This is AddReview.php:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Physicsguy's Reviews - Add Review</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="author" content="Scott Kaye" /> <meta name="description" content="If you have a review you would like to submit to PGREviews, type it into this box and submit it!" />
<link rel="stylesheet" href="physicsguystyle2.css" type="text/css" media="screen" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="lavatheme" href="physicsguystyle.css" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="rocktheme" href="physicsguystyle3.css" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="darkmattertheme" href="physicsguystyle4.css" /> <link rel="shortcut icon" href="http://www.webmaster-talk.com/images/favicon.ico" type="image/x-icon" /> <link rel="icon" href="http://www.webmaster-talk.com/images/favicon.ico" type="image/x-icons" /> <meta name = "viewport" content = "initial-scale = 1.0"> <script type="text/javascript" src="getscreen.js"> </script><!--This script should appear below your LINK stylesheet tags --><script src="styleswitch.js" type="text/javascript"> /*********************************************** * Style Sheet Switcher v1.1- © Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more ***********************************************/ </script></head><body><div id="container"><div id="banner"></div><div id="wrapper"><div id="main"><script type="text/javascript"> if (pageWidth() < 400) { document.writeln('<link rel="stylesheet" type="text/css" href="mobilestyle.css" />'); } </script> <script type="text/javascript"> if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { if (document.cookie.indexOf("iphone_redirect=false") == -1) document.writeln('<link rel="stylesheet" type="text/css" href="mobilestyle.css" />'); }</script> <!--Begin main content-->
<?php $reviewToAdd = $_POST['reviewfulladd']; $reviewSerialNum = $_POST['reviewserialnumber']; $translated = $_POST['reviewtrans'];
$fp = fopen("ffdatabase.txt","a");
if(!$fp) { echo " <div id='contentboxtitle'><h1>Error:</h1></div><div id='contentbox'>Your review was not submitted successfully. Please email <a href='mailto:physicsguy@pgreviews.com'>physicsguy@pgreviews.com</a>.< br /> <input type='button' value='Home' onclick='window.open('index.shtml','_self');' /> </div> "; exit; }
else { echo " <div id='contentboxtitle'><h1>Thank You!</h1></div><div id='contentbox'>Your review was submitted successfully! <form action='userreview.php?reviewID=$reviewSerialNum' method='post'> < </form> </div> "; }
fwrite($fp, $reviewToAdd."\n");
fclose($fp);
?> <?php
$ToAddToSNDB = "userreview.php?reviewID=$reviewSerialNum";
$fp = fopen("serialnumdb.txt","a");
if(!$fp) { echo " <div id='contentboxtitle'><h1>Error 2:</h1></div><div id='contentbox'>Your review was not submitted successfully. Please email <a href='mailto:physicsguy@pgreviews.com'>physicsguy@pgreviews.com</a>. <br /> <input type='button' value='Home' onclick='window.open('index.shtml','_self');' /> </div> "; exit; }
else { echo " <div id='contentboxtitle'><h1>Thank You 2!</h1></div><div id='contentbox'>Your review was submitted successfully! <form action='userreview.php?reviewID=$reviewSerialNum' method='post'> <input type='submit' value='See My Review' /> </form> </div> "; }
fwrite($fp, $ToAddToSNDB."\n");
fclose($fp);
?> <br /> <table style="border: 1px solid black" width="500px" height="50px" align="center"> <td><table align="center"><td> <input type="button" value="Go Back Home" onClick="window.open('index.shtml','_self');" /> <input type="button" value="Write Another Review" onClick="window.open('makeyourreview.php?action=agreed','_self');" /> </td></table></td></table>
<!--End main content-->
</div></div><div id="extension">
<!--Begin right side content-->
<?php include("form.html"); ?> <?php include("stylebuttons.htm"); ?>
<h2>Other Links</h12> <hr> <h3><a href="reviews.shtml">Go Back</a></h3> <hr> <a href="index.html">Back To Welcome</a>
<?php include("rightsidemenu.htm"); ?>
<!-- End right side content -->
</div><div id="navigation"><div id="navmenu"><ul>
<!-- Begin navigation links...add as necessary -->
<?php include("leftsidemenu.htm"); ?>
<!-- End navigation links -->
</ul></div></div>
<div id="footer"><p class="footspace">© 2009 Physicsguy | <a href="setup.shtml">Settings</a></p></div></div> </body> </html>
And this is userreview.php:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Physicsguy's Reviews - <?php echo ("$reviewTitle"); ?> - User Review</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="author" content="Scott Kaye" /> <meta name="description" content="Physicsguy's Reviews - Find tutorials, games, reviews, and even guitar tablature on Physicsguy's Reviews, your site for everything!" /> <meta name="keywords" content="Reviews, Games, Software, Tablature, Guitar, Hero, Rock, Band, Physicsguy, Physicsguy's, Reviews, Physics, Phun, Wii, PS3, Playstation, Nintendo, Linux, Ubuntu, Xmoto, Inkscape, HTML, CSS, Super, Mario, Bros, Theme, Legend, Of, Zelda, Scott, Kaye, Scott Kaye, Cool, Site" /> <link rel="stylesheet" href="physicsguystyle2.css" type="text/css" media="screen" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="lavatheme" href="physicsguystyle.css" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="rocktheme" href="physicsguystyle3.css" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="darkmattertheme" href="physicsguystyle4.css" /> <link rel="shortcut icon" href="http://www.webmaster-talk.com/images/favicon.ico" type="image/x-icon" /> <link rel="icon" href="http://www.webmaster-talk.com/images/favicon.ico" type="image/x-icons" /> <meta name="viewport" content="initial-scale = 1.0" /> <script type="text/javascript" src="getscreen.js"></script> <!--This script should appear below your LINK stylesheet tags -->
<script src="styleswitch.js" type="text/javascript"> /*********************************************** * Style Sheet Switcher v1.1- © Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more ***********************************************/ </script> </head> <body> <div id="container"><div id="banner"></div><div id="wrapper"><div id="main"> <script type="text/javascript"> if (pageWidth() < 400) { document.writeln('<link rel="stylesheet" type="text/css" href="mobilestyle.css" /> <h3>You are browsing Physicsguy\'s Reviews in mobile mode. All of the features are here, nothing has changed, other than the size and functionality of this site! <br /><br /> '); } </script> <script type="text/javascript"> if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { if (document.cookie.indexOf("iphone_redirect=false") == -1) document.writeln('<link rel="stylesheet" type="text/css" href="mobilestyle.css" />'); }</script> <!--Begin main content--> <?php $fp = fopen('serialnumdb.txt','r'); if (!$fp) {echo 'ERROR: Unable to open file.'; exit;}
while (!feof($fp)) { $line = fgets($fp,1024); //use 2048 if very long lines list ($field1) = split ('\|', $line); echo "$field1."; $fp++; }
fclose($fp); ?> <?php $fp = fopen('ffdatabase.txt','r'); if (!$fp) {echo 'ERROR: Unable to open file.'; exit;}
while (!feof($fp)) { $line = fgets($fp,1024); //use 2048 if very long lines list ($field1) = split ('\|', $line); echo "$field1."; $fp++; }
fclose($fp); ?>
userreview.php?reviewID=$reviewSerialNum
<!--End main content-->
</div></div><div id="extension">
<!--Begin right side content-->
<?php include("form.html"); ?> <?php include("stylebuttons.htm"); ?>
<h2>Other Links</h12> <hr> <h3><a href="reviews.shtml">Go Back</a></h3> <hr> <a href="index.html">Back To Welcome</a>
<?php include("rightsidemenu.htm"); ?>
<hr />
<a href="setup.shtml">Settings</a>
<!-- End right side content -->
</div><div id="navigation"><div id="navmenu"><ul>
<!-- Begin navigation links...add as necessary -->
<?php include("leftsidemenu.htm"); ?>
<!-- End navigation links -->
</ul></div></div>
<div id="footer"><p class="footspace">© 2009 Physicsguy | <a href="setup.shtml">Settings</a></p></div></div> </body> </html>
You see, I'm having trouble with this. Here's my step checklist:
✓ 1. When you agree to the Terms, it displays the review form.
✓ 2. Allow you to edit or add the review, after it validates.
3. Add the review content (with serial number, and delimeters, the whole thing) to 'ffdatabase.txt', and add a string which contains the serial number, and the URL for that (looking something like "userreview.php?reviewID=$serialNumString") to a database called "serialnumdb.txt".
4. Have a page that pulls all the information from 'serialnumdb.txt', look for the serial number that it has in the page's URL, and then look into 'ffdatabase.txt' for that serial number, followed by the review, and display it.
5. EXTRA, OPTIONAL: Allow the user to edit their own reviews, but not other user's. Again, only if things are running perfectly.
It's tough, it's big, but it's worth it!
Also, thank you for your help Jeremy Miller!
And JM, I was just looking at your TeraTask site - nice - but I notice that you are doing the same thing I want to do. All your pages are "index.php?page=SOMETHING" which is what I want except "userreview.php?reviewID=$serialNumString"! No wonder you understand, you have the same kind of thing! Nice. :O
Last edited by Physicsguy; 09-14-2009 at 06:45 PM..
|
|
|
|
09-14-2009, 06:41 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
|
I'm on a tight deadline today and don't have a chance to look at it now, but if no one else has chimed in by tomorrow, I'll take another look. 
__________________
Jeremy Miller
Please login or register to view this content. Registration is FREE
|
|
|
|
09-15-2009, 04:47 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 824
Name: Scott
Location: Ontario
|
Thanks!
I'll also take a look at Content Farmer! Looks neat!
|
|
|
|
09-15-2009, 06:13 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
|
No need to look at content farmer. I'm so busy that I've temporarily suspended sales anyway.
I'll look at your code in a couple of hours. Were you able to make any progress?
__________________
Jeremy Miller
Please login or register to view this content. Registration is FREE
|
|
|
|
09-15-2009, 08:37 PM
|
Re: Add 1 To $reviewnum When User Clicks Submit?
|
Posts: 824
Name: Scott
Location: Ontario
|
Not in that area, I'm working on a different feature (character maximum and minimum)
|
|
|
|
|
« Reply to Add 1 To $reviewnum When User Clicks Submit?
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|