Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing form values and moving to another page
    text
    copied!<p>I am beginner in web development and doing HTML with PHP and MySQL. I am trying to read data from a user using a form, and on the click "save", I need to submit the form values to the same file and move to another page.</p> <p>The values are used by PHP object in the same file in order to invoke a method that handles these values. </p> <p>Unfortunately, the submitted values are lost and seem to go nowhere. Further, I am not moving to the desired (another) page.</p> <p>Here's my form. ( the current file is named "Insert.php" and I am showing one element only).</p> <pre><code>&lt;form method="post" action= "Insert.php"&gt; &lt;fieldset&gt; &lt;legend&gt;Insert New Data &lt;/legend&gt; &lt;p&gt; Service Name : &lt;select name="service_name"&gt; &lt;option value=""&gt; &lt;/option&gt; &lt;?php $result = $db_link-&gt;query("SELECT * FROM servicetype_lookup "); while($row= $result-&gt;fetch_row()) { $id = $row[0]; $value = $row[1]; echo "&lt;option value='$id'&gt;$value&lt;/option&gt;"; } ?&gt; &lt;/select&gt; ......... ......... </code></pre> <p>In the same file "Index.php", I am sending the values to a function in another file that contains a class called "AccountHolder" as the following:</p> <pre><code>&lt;?php if(isset ($_POST['service_name'] ) ) { $account_holder= new AccountHolder; $result= $account_holder-&gt;insert($_POST['service_name'] , $_POST['reference'], $_POST['title'], $_POST['risk_rating'], $_POST['root_cause'], $_POST['impact'], $_POST['likelihood'], $_POST['efforts'], $_POST['finding'], $_POST['implication'], $_POST['recommendation'] ); } ?&gt; </code></pre> <p>and finally I have this submit button that should move to another page called "Database.php" (This is not the page that contains the class AccountHolder):</p> <pre><code> &lt;br/&gt;&lt;input type="submit" value=" Save " onclick="window.location.href='Database.php'" /&gt; </code></pre> <p>Can someone help? Thank you.</p>
 

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