Results 1 to 2 of 2

Thread: PHP doesn't redirect to the specified location

  1. #1
    Join Date
    Nov 2015
    St. Petersburg, Russia

    Question PHP doesn't redirect to the specified location

    Even if my code has the
    HTML Code:
    header('Location: /user/?tab=captures&msg=updated');
    it doesn't redirect either. How to solve this?

    PHP Code:
        if (isset($_POST['chosen'])) {
    $query "UPDATE users SET template = ? WHERE username = ?";
    $stmt $tubcConnection->prepare($query);
    $stmt->bind_param('ss'$_POST['chosen'], $user);
            if (
    $stmt->affected_rows === 1) {
    header('Location: /user/?tab=captures&msg=updated');
    HTML Code:
        <form id="capture-form" action="/account/?tab=captures" method="post">
            <input type="hidden" id="chosen" name="chosen" value="default" />

  2. #2
    Join Date
    Aug 2004
    Do you have error reporting turned on? Most likely cause would be that headers have already been sent by the time you call header(), which would result in a PHP warning. If you want to test it explicitly:
    PHP Code:
            if ($stmt->affected_rows === 1) {
    headers_sent($file$line)) {
    "Headers already sent in $file at line $line");
    header('Location: /user/?tab=captures&msg=updated');
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center