Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can hand over values to another page by...</p> <p><strong>(1) QUERYSTRING (URL)</strong></p> <pre><code>page.php?do=show&amp;id=5 </code></pre> <p>create those by pulling the unique id of a record from your db and create a link:</p> <pre><code>echo "&lt;a href=\"page.php?id={$row['id']}\" /&gt;{$row['name']}&lt;/a&gt;"; </code></pre> <p>assuming that your table <code>imgz</code> has the fields id, name.</p> <p>in page.php, you get those variables with</p> <pre><code>$_GET['do']; $_GET['id']; </code></pre> <p><strong>pro</strong>: quick &amp; easy<br> <strong>contra</strong>: can be easily manipulated by evil users - they change the querystring and get your script to do weird things.</p> <p><strong>(2) POST</strong></p> <p>create a <code>&lt;form method="post" action="page.php"&gt;</code>with a hidden field named <code>id</code> containing the 'id' you want to pass. Add a <code>&lt;submit&gt;</code>-button to send the data to page.php.</p> <p>in page.php, you get those values by:</p> <pre><code>$_POST['id']; </code></pre> <p><strong>pro:</strong> safe, because evil user can't fiddle with POST<br> <strong>contra:</strong> overhead</p> <p><strong>(3) SESSION:</strong></p> <p>call <code>session_start();</code> on top of every page, write your data into the session by...</p> <pre><code>$_SESSION['id'] = $id; $_SESSION['do'] = "show"; </code></pre> <p>these variables will be kept between pages, in page.php you can simply use <code>S_SESSION['id']</code> and have that value - if you called <code>session_start()</code>.</p> <p><strong>pro:</strong> easy and safe, PHP will do the work for you (e.g. handling cookies etc.)<br> <strong>contra:</strong> will put load on your webserver if traffic goes up on your site.</p>
    singulars
    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