Jump to content

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?
Link to comment
https://forums.phpfreaks.com/topic/17197-edit-submission/
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.