Treehouse: Grow your CSS skills. Land your dream job.

Form Submit Error[PLEASE HELP!!]

  • # May 26, 2013 at 2:19 am

    i am having a profile.php page and in that page i am having a form but it’s action is not working correctly.

    The code is(i have all <> in the form code below but it’s not here as it was not showing so i removed them)-


    But when i click on add as friend or send message it sends me to :- instead i want to submit to the the same page in which username is logged in.

    can i use `< ? echo $username; ?>` but using it sends me to 404 page and i don’t want to use .htaccess.

    $username stands for and form code :-

    < ?
    if(isset($_GET)) {
    $username = mysql_real_escape_string($_GET);
    if(ctype_alnum($username)) {
    //check user exists
    $check = mysql_query(“SELECT username,first_name FROM users WHERE username=’$username'”);
    if(mysql_num_rows($check)===1) {
    $get = mysql_fetch_assoc($check);
    $username = $get;
    $username = $get;
    echo ““;
    what should i do please help as i want to direct to the same page in which user’s profile is.

    # May 26, 2013 at 8:51 pm

    You are assigning `$username` to two different values in a row (the first value will be overwritten).

    The `` tag you are writing is malformed.

    Instead of writing a `` redirect, it would be much better to use PHP’s [`header()`]( function.

    I can give you an example if you let me know what URL you want to redirect to.

    # May 27, 2013 at 6:02 pm

    i recommend you to use PDO and prepared statements instead of mysql.
    its safer and mysql_* functions will be deprecated.

    I know its not the answer to your question but i still think it will help you:)

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.