Jump to content

Leaving Comments


inversepsychology

Recommended Posts

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,

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.