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
https://forums.phpfreaks.com/topic/169551-solved-another-_post-problem/
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 ??  ;)

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

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" );
        }

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.