Grant Holmes Posted February 16, 2008 Share Posted February 16, 2008 Hey gang, this one might be a stretch, but hey its Saturday right? Here's the scenario. Due to my inability to have all this PHP stuff down yet, I use a form generator from Forms To Go to produce a "processing" page that processes a given form. They work great, especially when someone enters an apostrophe (Dad's). I have a "backend" page where I can process the record the processing page puts in my table. I display certain records with an edit call in the last cell of the row, then pass the edit to another page. The edit page is working correctly and allows me to edit my table, but does NOT like apostrophes or other nonsense that the processing form handles well. I'm thinking, why not use a somewhat duplicate version of the above processing page to update the record. I KNOW there are two problems. The processing page is always creating a new record. It wouldn't know what record to update unless I passed it the row/record number. So on the display page (showing all records/fields), I show the edit link in the last cell; <TD valign="top"><CENTER> <a href='songs_edit.php?id=<? echo "$id"; ?>'>edit</a><TD> On the edit page I have all the stuff to process the edit: <form method="post"> <input type="hidden" name="ud_id" value="<? echo $id; ?>"> //********Blah, blah to display and allow editing of fields...one instance: Record Label:<input type="text" name="ud_RecordLabel" value="<? echo $RecordLabel; ?>"> // Then: <input type="submit" name="submit" value="Update"> <BR><BR><input type=button value="Cancel" onClick="history.go(-1)"><BR><BR> <input type="submit" name="submit" value="Delete" onClick="return confirm('Are you sure you want to delete this record? This cannot be undone!')"> (In this case I'd be posting to the form instead, but that's whats there now) So that should pass the record number. In the processing form, after it does all the text processing, it uses this section to post to the table: $mysql_link = @mysql_connect("localhost", "Table", "PassWord"); if (mysql_errno() == 0) { @mysql_select_db("music", $mysql_link); if (mysql_errno() == 0) { $sqlcmd = sprintf("INSERT INTO `SongList`(`SongTitle`, `ArtistPrimary`, `ArtistSecondary`, `WriterPrimary`, `WriterSecondary`, `RelatedURL`, `Comments`, `PartOf`, `SongStatus`, `SongPace`, `Minutes`, `YearRecorded`, `YearWritten`, `RecordLabel`, `Lyrics`, `active`) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", mysql_real_escape_string($FTG_SongTitle, $mysql_link), mysql_real_escape_string($FTG_ArtistPrimary, $mysql_link), mysql_real_escape_string($FTG_ArtistSecondary, $mysql_link), mysql_real_escape_string($FTG_WriterPrimary, $mysql_link), mysql_real_escape_string($FTG_WriterSecondary, $mysql_link), mysql_real_escape_string($FTG_RelatedURL, $mysql_link), mysql_real_escape_string($FTG_Comments, $mysql_link), mysql_real_escape_string($FTG_PartOf, $mysql_link), mysql_real_escape_string($FTG_SongStatus, $mysql_link), mysql_real_escape_string($FTG_SongPace, $mysql_link), mysql_real_escape_string($FTG_Minutes, $mysql_link), mysql_real_escape_string($FTG_YearRecorded, $mysql_link), mysql_real_escape_string($FTG_YearWritten, $mysql_link), mysql_real_escape_string($FTG_RecordLabel, $mysql_link), mysql_real_escape_string($FTG_Lyrics, $mysql_link), mysql_real_escape_string($FTG_active, $mysql_link)); @mysql_query($sqlcmd, $mysql_link); } # Redirect user to success page header("Location: http://www.MySite.com/SuccessPage.php"); exit; ?> Is this enough info? Is this possible to modify the processing form?? Asking too much?????? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.