mischievousx3 Posted March 17, 2011 Share Posted March 17, 2011 I'm having a problem with adding icon/avatar to my database..this is a submit form where I just submit the avatar url. I don't know how to change the submit link from avatar_add.php?mode=submit to index.php?mode=submit&x=avatar_add. http://www.graphics.allmerk-noplay.com/index.php?x=avatar_add <?php $host =""; // host name $user =""; // user $pass =""; // password $dbase =""; // database name // connect to the server mysql_connect("$host","$user","$pass"); // and select the database mysql_select_db($dbase); $mode=$_GET["mode"]; // get the mode $QUERY_STRING = 'x=avatar_add'; if(!isset($mode) || empty($mode)) // if mode is empty, switch to case index { $mode='index'; } switch($mode) { case 'index'; // displays the form ?> <form method="post" action="avatar_add.php?mode=submit"> Avatar URL:<br> <input type="text" name="avatar_url" size="30"><br><br> <input type="submit" value="Submit"> <?php break; case 'submit'; // form processing mode $avatar_url=$_POST["avatar_url"]; // check for empty fields if(empty($avatar_url)) { echo "Error! Please go back and fill in all the required fields!"; // if you have a footer include, insert it before the die statement die; // stops the script from executing the rest of the code } // let's get the date in YYYY-MM-DD format $date = date("Y-m-d"); $query="INSERT into icons_db (id,avatar_url) VALUES ('','$avatar_url')"; $result=mysql_query($query) or die ("Couldnot execute query: $query." . mysql_error()); if($result) // if mysql query successful { echo "Thank you! The avatar has been added to or database."; } break; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/230932-database-query-isnt-working/ Share on other sites More sharing options...
ChemicalBliss Posted March 17, 2011 Share Posted March 17, 2011 You have solved your own problem in your post. just change the url in the action attribute of the form tag element to what you need. Quote Link to comment https://forums.phpfreaks.com/topic/230932-database-query-isnt-working/#findComment-1188761 Share on other sites More sharing options...
Maq Posted March 17, 2011 Share Posted March 17, 2011 Use tags in the future. Quote Link to comment https://forums.phpfreaks.com/topic/230932-database-query-isnt-working/#findComment-1188767 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.