loading edit form only if GET var exists in database

ozmita

New Member
What my script currently does:
  • grabs & cleans a $_GET['id']
  • pulls all pre-existing data from TABLE for that id
  • displays form populated with any pre-existing data
  • SUBMIT sends form data to update script, adds all data to TABLE
What I want my script to do:
  • grabs & cleans a $_GET['id']
  • pulls all possible (id)'s from TABLE (this I know how to do)
  • checks that \[code\]$_GET['id']\[/code\] is in array ID (this I know how to do)
  • IF NOT, kill script, do not display form, and echo error message (this I don't)
  • IF YES, proceed as normal
  • pulls all pre-existing data from TABLE for that id
  • displays form populated with any pre-existing data
  • SUBMIT sends form data to update script, adds all data to TABLE
Current script structure:
  • php code
  • html form with \[code\]<?php _ ?>\[/code\] inserts for all values
I've tried to be a good lad and separate my code, and have largely succeeded. But that's left me with the problem that my html form displays whether the \[code\]$_GET['id']\[/code\] is legit or not.Could someone please help me set it up so that \[code\]if (!in_array($id, $allIDs))\[/code\] prevents the form from displaying and tosses out an error instead?Other than making the form an echoed HEREDOC, is there a way to control the display of that html?Psuedocode is acceptable. I didn't bother posting my actual code because I didn't think the problem really merited such specificity. I can if need be...
 
Back
Top