Note that there are some explanatory texts on larger screens.

plurals
  1. POtrying to redirect after submitting data
    primarykey
    data
    text
    <p>i am trying to redirect after submitting some data into my database to example.php i have the form and it submits perfect but cant get the redirect to work i have tried a few methods i have seen on the internet but nothing worked</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;MySQLi Create Record&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php $action = isset($_POST['action']) ? $_POST['action'] : ""; if($action=='create'){ //include database connection include 'db_connect.php'; //write query $query = "insert into referb set make = '".$mysqli-&gt;real_escape_string($_POST['make'])."', model = '".$mysqli-&gt;real_escape_string($_POST['model'])."', unitt = '".$mysqli-&gt;real_escape_string($_POST['unitt'])."'"; if( $mysqli-&gt;query($query) ) { echo " header( 'Location: example.php' ) ;"; }else{ echo "Database Error: Unable to create record."; } $mysqli-&gt;close(); } ?&gt; &lt;!--we have our html form here where user information will be entered--&gt; &lt;form action='#' method='post' border='0'&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Manufactor&lt;/td&gt; &lt;td&gt;&lt;input type='text' name='make' /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Model&lt;/td&gt; &lt;td&gt;&lt;input type='text' name='model' /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Unit Type&lt;/td&gt; &lt;td&gt; &lt;select name='unitt'&gt; &lt;option&gt;Laptop&lt;/option&gt; &lt;option&gt;Computer&lt;/option&gt; &lt;option&gt;Tablet&lt;/option&gt; &lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt; &lt;input type='hidden' name='action' value='create' /&gt; &lt;input type='submit' value='Save' /&gt; &lt;a href='index.php'&gt;Back to index&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload