mardi 5 mai 2015

header function isnt redirecting to the correct webpage

I am trying to use the header function in php. For some reason it is not redirecting to the correct webpage, it just stays on the same one. However when I copy and paste the url to my web browser it is the correct url and it takes me to the page. Maybe I am missing a quote or something but I cant figure it out for the life of me so maybe someone here can show me what i am doing wrong.

This page is called home.php

<form method="POST", action="home.php">
<select id="database" name="database">
    <option selected="selected" disabled="disabled">Database</option>
</select>

<select id="evalue" name="evalue">
    <option selected="selected" disabled="disabled"> evalue <option>
    <option value="0.0001">0.0001</option>
 </select>

<select id="hits" name="hits">
    <option selected="selected" disabled="disabled"> Hits</option>
    <option value="50">50</option>
</select>
<input id="BlastSearch" type="text" name="BlastSearch" value='' />
<input type="submit" name="submit" value="submit" />
<button type="reset" value="Clear">Clear</button>
</form>


<?php
    session_start();
    //if statement to check if the user is signed in or not
    //if (isset($_SESSION['username'] && $_SESSION['loggedin'] == 'true')){


    require_once '../secure/database.php';
    $mysqli = new mysqli($dbhost,$dbuser,$dbpass,$dbname);

    if($mysqli->connect_error){
            exit('CON Error: ' . $mysqli->connect_errno . ' ' . $mysqli->connect_error);
    }

    //Insert the values into the database

    if(isset($_POST['submit'])){

            //declare variables to what the user defines them as
            $db = $_POST['database'];
            $evalue = $_POST['evalue'];
            $sequence = $_POST['BlastSearch'];
            $hits = $_POST['hits'];


            //create a new .fasta file and put the sequence the user wants to search for in that file

            $file = 'uploads/new.fasta';

            $current = $_POST['BlastSearch'];
            file_put_contents($file, $current);
            $userid = $_SESSION['uid'];

            //insert the values into the database
            $mysqli->query("INSERT INTO `Job` (`uid`, `input`, `status`, `start_time`, `finish_time`) VALUES ('1', '" . $sequence . "', 'running' , NOW(), NOW())");
            exec('/students/groups/cs4380sp15grp4/blast/blast-2.2.26/bin/blastall -p blastp -d db -i /students/groups/cs4380sp15grp4/public_html/home/uploads/new.fasta -m'.$evalue.' -o output -v'.$hits.' -b'.$hits);

            header('Location: http://ift.tt/1bwLU2z');
    exit();
    }
?>

I dont understand, when the button is pressed it should go to that url, but it doesnt redirect it just stays on the home page.

Aucun commentaire:

Enregistrer un commentaire