Find the answers to many of your expat questions here

View Latest Posts

You're missing out...

As a member you can enjoy exclusive info and offers.


Need a webmaster's help automating a page w/MX

Posted by nicevictory - Created: 15 years ago
0 0
Sorry no image available

1 reply

Sorry no image available
Posted by JohnD-185075 - 15 years ago

Here's how I would do it if I just wanted a really basic system (N.B. personally I probably wouldn't use ASP or Dreamweaver, but the principles are the same). I would use several pages (although it could probably be done with just one or two):index.aspOn the left hand side there are 2 buttons labelled 'Insert' and 'Query'. The 'Insert' button links to a page called "enterdata.asp" and sends the HTTP request variable $action with the value 'insert' (i.e. it links to "enterdata.asp?action=insert". The 'Query' button links to a page called "viewdata.asp".On the right hand side of the page is just a welcome message.viewdata.aspThe 'Insert' and 'Query' buttons are on the left. A list of all records from the database is displayed on the right. This could be split over several pages using a $page_id variable or similar. Next to each record there is an 'Edit' button that links to "enterdata.asp" with a value of 'edit' for the $action variable, and another variable named $record_id containing the record id from the database (so it would link to "enterdata.asp?action=edit&record_id=69", for example).enterdata.aspThe 'Insert' and 'Query' buttons are displayed on the left. A form is displayed on the right. This form can either be used to add a new record to the database, or edit an existing one, depending on the value of $action:'insert': display a blank form ready to be filled in by the user.'edit': Do something like "SELECT * FROM mytable WHERE record_id = $record_id" and populate your form with the data that it returns (if $record_id doesn't exist, display an error).(neither): Display an error messageThere should be a hidden field containing the value of $action (and $record_id if $action == 'edit'). When the user clicks 'submit', it posts the form data to "submitdata.asp".submitdata.aspCheck that the values that the user has entered for each field are valid. If not, immediately go back to enterdata.asp with the errors highlighted in red. Remember that if $action == 'edit' then $record_id must have a value that already exists in the database otherwise you will get an error. If the data is all OK, perform a database insertion/update (depending on the value of $action), and display a message saying that the insertion/update was successful, with a link to go back to the main page.