Jump to content

Archived

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

Lessur

Edit Submission

Recommended Posts

Ok, I have an flash submission system.  You upload the flash file, along with some comments, a title, etc, it puts the information in a mySQL database, give it an id, and you can access it via view.php?id=(id here).

I want to make an edit submission page, so I did the following, for editsub.php:

[code]<?php
  if ($_SESSION['username']){
 
  $sql=mysql_query("SELECT * FROM `portal` ORDER BY id DESC LIMIT 0 , 200 ") or die(mysql_error());

  while ($row=mysql_fetch_array($sql)){

  $i++;

  $id=$row['id']; //Id

  $title=stripslashes($row['title']); //Title

  $author=stripslashes($row['user']); //Username
 
  $small_image=stripslashes($row['small_image']); //Small icon to go with the submission


  if ($author == $username){ echo "<a href='editsub2.php?id=$id'><img src='small_images/$small_image' width='50' height='50' border='0'>&nbsp;&nbsp;$title by $author</a><br>"; } else{ echo ""; } } } else { echo "<div align='center'>You must be logged in to edit submissions!</div>"; }?>[/code]

That, you access when you are logged in, generating a page with all of your submissions on it.  Now, if you may have noticed, each links to editsub2.php?id=$id .

This is editsub2.php:

[code]<?php
if (is_numeric($_GET['id'])){

if ($_SESSION['username']){

if ($_GET['submit']){

$check=mysql_num_rows(mysql_query("SELECT * FROM `portal` WHERE id = '$id' LIMIT 1"));

if ($check == 1){

$sql=mysql_query("SELECT * FROM `portal` WHERE id = '$id' LIMIT 1");

$row=mysql_fetch_array($sql);

$title_show=stripslashes($row['title']);

$wide_show = stripslashes($row['wide']);

$high_show = stripslashes($row['high']);

$title_show=stripslashes($row['title']);

$author_show=stripslashes($row['user']);

$desc_show=stripslashes($row['desc']);
// USED TO UPDATE DATABASE
$title=addslashes(strip_tags($_POST['title']));

$desc=addslashes(strip_tags($_POST['desc']));

$wide=addslashes(strip_tags($_POST['wide']));

$high=addslashes(strip_tags($_POST['high']));

$terms=addslashes(strip_tags($_POST['terms']));



if ($title == ""){

echo "Field title left blank <a href='?'>Go back?</a>";

}

elseif($desc == ""){

echo "Field desccription left blank <a href='?'>Go back?</a>";

}

elseif ($wide == ""){

echo "Field width left blank <a href='?'>Go back?</a>";

}

elseif ($high == ""){

echo "Field height left blank <a href='?'>Go back?</a>";

}

elseif (!is_numeric($wide) || !is_numeric($high)){

echo "Field width or height false <a href='?'>Go back?</a>";

}

elseif ($terms == ""){

echo "You did not agree to are Terms of Use! <a href='?'>Go back?</a>";

}

else{

$sql=mysql_query("UPDATE `portal` ( `title` , `desc` , `wide` , `high`) VALUES ('$title', '$desc', '$wide', '$high')");

if ($sql){

echo "Success! Submission updated!! - <a href='index.php'>Index!</a>";

}

else {

echo "Failed";

}[/code]

I have a form on the page also, with:

[code]<input name="title" type="text" id="title" value="<?php echo "$title_show"; ?>" size="20" maxlength="15">[/code]

For example.  So to my understanding, this should work.  On editsub2.php it should show the $title_show in the database as the value for the textboxes, and should update the submission.  but this does not work.  It does not give the values to the textboxes, and when i click the submit button, it clicks and nothing happens.

Help?

Share this post


Link to post
Share on other sites
is your form tag look like
<form .. action="?id=$id&submit='OK'"

Share this post


Link to post
Share on other sites
" <form .. action="?id=$id&submit='OK'" "

?  could you include it all please?

Share this post


Link to post
Share on other sites

×

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.