Jump to content

[SOLVED] Another $_POST Problem


Gayner

Recommended Posts

Sorry for Double post, but I have a problem, im trying to do this but it just keep's refreshing:

 

if ( $_POST['remove'] )
        {
            mysql_query("UPDATE ibf_members SET avatar='". mysql_real_escape_string(' ') ."' WHERE id={$ibforums->member['id']}");
	 header("Location: index.php?act=UserCP&CODE=Avatar");

        }


if(isset($_POST['avatar'])){
            $ext = explode ( "|", 'gif|jpeg|jpg|png' );
            $checked = 0;
            $av_ext = preg_replace( "/^.*\.(\S+)$/", "\\1", $_POST['avatar'] );

            foreach ($ext as $v )
            {
                if (strtolower($v) == strtolower($av_ext))
                {
                    $checked = 1;
                }
            }
            if ($checked != 1)
            {
                $std->Error( array( 'LEVEL' => 1, 'MSG' => 'avatar_invalid_ext' ) );
            }
	 mysql_query("UPDATE ibf_members SET avatar='". mysql_real_escape_string($_POST['avatar']) ."' WHERE id={$ibforums->member['id']}");
	 header("Location: index.php?act=UserCP&CODE=Avatar");
}

 

MY HTML IS:

<form name="form" method="post">
<input type="text" size=50 name="avatar" value="{$ibforums->member['monkavatar']}">
<input type="Submit" value="Update Avatar"> | <input type="submit" name="remove" value="Remove Avatar">

 

Now whenever I click on Remove Avatar it just refreshes my page, the name for The Remove avatar submit is "remove" it should follow my $_POST['remove'] right? it's not :(

Link to comment
Share on other sites

you need to change this

<input type="submit" name="remove" value="Remove Avatar">

to

<input type="button" name="remove" value="Remove Avatar" onclick ="Put the javascript in here">

or make another form that passes the id to remove or update the databse as 1 form shouldnot have 2 submit buttons. you are confusing the HTML ??  ;)

Link to comment
Share on other sites

Well, what you should do is this. If your PHP is within the same page..

 

<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">

 

Or..

 

<form name="form" method="post" action="process.php">

 

This makes it so the FORM's Submit button actually sends a POST to.. process.php or $_POST['form']; variable in your PHP code..

Link to comment
Share on other sites

Haha I fixed it..

 

You guys are all wrong? lol it's working just fine for me.

 

if ( $_POST['remove'] )
        {
            $DB->query("UPDATE ibf_members SET monkavatar='' WHERE id='{$ibforums->member['id']}'");

            $print->redirect_screen( 'Thanks avatar is Removed!', "act=UserCP&CODE=Avatar" );
        }

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.