Jump to content

view submission before entering DB


frijole

Recommended Posts

I am setting up a content management script here where I can add videos to my database, everything is working here. I am trying to come up with a way to view the submitted video. and description before it gets added to the database to make sure everything is correct. Any ideas?

 

<?php
if(!$_POST){?>

<html>

<table>

<tr>
<td> <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> Embed HTML:</td> 
    <td> <textarea rows="5" cols="50" wrap="virtual" name="embedHTML"> Enter Embed HTML Here </textarea></td>
</tr>

<tr>
<td>Description: </td>
<td><textarea rows="5" cols="50" wrap="physical" name="description"> Describe The Video Here </textarea></td>
</tr>

<tr>
<td><input type="submit" value="Add Video!"></form></td>
</tr>

</table>

</html>

<?php
} else {
if (isset($_POST['embedHTML'])||isset($_POST['description']))
{
require_once("dbConnect.php");

$embedHTML = trim(mysql_real_escape_string($_POST['embedHTML']));
$videoDesc = trim(mysql_real_escape_string($_POST['description']));

$query = "INSERT INTO videos (embed_html, description) VALUES ('$embedHTML', '$videoDesc')";

$result2=mysql_query($query) or die(mysql_error());
}

if($result2){

echo "video added to the DB!";}
elseif(empty($result2)){ echo "The Fields Are empty";}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/95026-view-submission-before-entering-db/
Share on other sites

redirect the form to "whatever.php?a=review"

<?php
if($action == 'review'){
echo $_POST['embedHTML'];
echo $_POST['description'];
echo 'Like what you see? <a href="whatever.php?a=confirmed">Upload</a> video!';
}
if($action == 'confirmed'){
if (isset($_POST['embedHTML'])||isset($_POST['description']))
{
require_once("dbConnect.php");

$embedHTML = trim(mysql_real_escape_string($_POST['embedHTML']));
$videoDesc = trim(mysql_real_escape_string($_POST['description']));

$query = "INSERT INTO videos (embed_html, description) VALUES ('$embedHTML', '$videoDesc')";

$result2=mysql_query($query) or die(mysql_error());
}

if($result2){

echo "video added to the DB!";}
elseif(empty($result2)){ echo "The Fields Are empty";}
}}
?>

You could add a field.  Insert a 0 in it by default and after you view it set it to 1.  On all pages search for videos with a 1 in this field.

 

This is the method I have used in the past, although it's not very effective when you have hundreds of entries piling up on you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.