inversepsychology Posted January 12, 2008 Share Posted January 12, 2008 Hello everyone. My website, www.inversepsychology.com, currently hosts various videos. I am looking for a way for people to be able to leave a comment on these videos ie. Youtube. There doesn't need to be an logging in to leave comments as of now, I'd just like a way for people to fill out a form and have it automatically posted. Is there a php script hat could do that, or could someone point me in the direction of where i could learn to do that? Thanks, Quote Link to comment Share on other sites More sharing options...
mr_mind Posted January 12, 2008 Share Posted January 12, 2008 google mysql and PHP Quote Link to comment Share on other sites More sharing options...
inversepsychology Posted January 12, 2008 Author Share Posted January 12, 2008 So basically I would create a script that would take the user input and store it in the db. Then I would have another script pull from the db and display the message? Quote Link to comment Share on other sites More sharing options...
revraz Posted January 12, 2008 Share Posted January 12, 2008 Yep, or the same script to do both but does it based on how you load the page, like using $_GET Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted January 12, 2008 Share Posted January 12, 2008 what you need is a basic POST form, or GET, but POST is easier I reckon. And you have a basic form like this: <form name="whatever" method="post" action="http://www.yourwebsite.com/comments.php"> <input name="comment" type="text"> <input name="author" type="text"> <input name="video_id" type="hidden" value="<?php echo $vid_id; ?>"> <!-- Grab the video's id and put it in this field --> <input type="submit" value="Submit Comment"> now a user goes onto your website, they watch a video, and fill out the above form and press Submit Comment. Now comments.php processes the form. comments.php <?php // Connect to MySQL and database here, I assume you already know how to do this... if not google it /* then you do mysql_insert(); you do this twice, 1 for the comment, and 1 for the author. using $_POST["comment"]; and $_POST["author"]; and with the INSERT you use the WHERE clause and put WHERE videoid = $_POST["video_id"]; (or whatever your video id field is called) */ // then you thankyou for there submission, or redirect them back to the video // Thankyou echo "Thankyou for your Comment"; // or redirect header("http://www.yourwebsite.com/index.php?page=video&id=$_POST[\"video_id\"];"); // or header("http://www.yourwebsite.com/view_video.php"); // or where ever the video is ?> I hope this helps. Note: this is very very basic, and may or may not make sense as I am absolutely a zombie right now due to lack of sleep. Regards ACE Quote Link to comment Share on other sites More sharing options...
twostars Posted January 12, 2008 Share Posted January 12, 2008 what you need is a basic POST form, or GET, but POST is easier I reckon. And you have a basic form like this: <form name="whatever" method="post" action="http://www.yourwebsite.com/comments.php"> <input name="comment" type="text"> <input name="author" type="text"> <input name="video_id" type="hidden" value="<?php echo $vid_id; ?>"> <!-- Grab the video's id and put it in this field --> <input type="submit" value="Submit Comment"> now a user goes onto your website, they watch a video, and fill out the above form and press Submit Comment. Now comments.php processes the form. comments.php <?php // Connect to MySQL and database here, I assume you already know how to do this... if not google it /* then you do mysql_insert(); you do this twice, 1 for the comment, and 1 for the author. using $_POST["comment"]; and $_POST["author"]; and with the INSERT you use the WHERE clause and put WHERE videoid = $_POST["video_id"]; (or whatever your video id field is called) */ // then you thankyou for there submission, or redirect them back to the video // Thankyou echo "Thankyou for your Comment"; // or redirect header("http://www.yourwebsite.com/index.php?page=video&id=$_POST[\"video_id\"];"); // or header("http://www.yourwebsite.com/view_video.php"); // or where ever the video is ?> I hope this helps. Note: this is very very basic, and may or may not make sense as I am absolutely a zombie right now due to lack of sleep. Regards ACE Just clarifying that the second script will not work, as its mainly to comment different things you could do. You won't be able to use it as you can't send headers (ie: the echoed data), then try and send some more (ie: the redirects). PS: I will be more than happy to code this script for you, for a small price. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted January 12, 2008 Share Posted January 12, 2008 just a quick note twostars, I don't think he is too good with web design. Take a look at his website... :-\ Quote Link to comment Share on other sites More sharing options...
twostars Posted January 12, 2008 Share Posted January 12, 2008 just a quick note twostars, I don't think he is too good with web design. Take a look at his website... :-\ I would, but its not connecting. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.