kevinritt Posted January 11, 2009 Share Posted January 11, 2009 I am looking for a decent tutorial to create an address book using php and mysql. I have a basic understanding of both but I want to learn update, add and delete concepts. I found a decent tutorial here http://php.about.com/od/finishedphp1/ss/address_book.htm but I can't get the source code (page not found). An example of the code is: if ( $mode=="add") { Print '<h2>Add Contact</h2> <p> <form action=';echo $PHP_SELF; Print 'method=post> <table> <tr><td>Name:</td><td><input type="text" name="name" /></td></tr> <tr><td>Phone:</td><td><input type="text" name="phone" /></td></tr> <tr><td>Email:</td><td><input type="text" name="email" /></td></tr> <tr><td colspan="2" align="center"><input type="submit" /></td></tr> <input type=hidden name=mode value=added> </table> </form> <p>'; } if ( $mode=="added") { mysql_query ("INSERT INTO address (name, phone, email) VALUES ('$name', '$phone', '$email')"); } this is where I get stuck. How do I create the link to pull up either add, edit or delete? Thanks Link to comment https://forums.phpfreaks.com/topic/140425-php-mysql-address-book/ Share on other sites More sharing options...
npsari Posted January 11, 2009 Share Posted January 11, 2009 I am not sure what you mean by 'to pull up' All i know is this ... In the page you linked to, it gives you a php code which will create the mySQL table for you So, after you are done with that, you will use the HTML form to submit the data, then, you will use the simple INSERT to save the data in that table The whole idea is easy, you can do it yourself, i mean create your own field_names and table, it will give you good experience for the future Link to comment https://forums.phpfreaks.com/topic/140425-php-mysql-address-book/#findComment-734944 Share on other sites More sharing options...
kevinritt Posted January 11, 2009 Author Share Posted January 11, 2009 Sorry , I wasn't clear. Looking at the link of the tutorial, you'll see the edit link to the right and then the remove(delete). I'm not sure what to use as a link to go to the ( $mode=="add") section of the script. Would it be something as simple as <a href="index.php?mode=add">add</a>? Link to comment https://forums.phpfreaks.com/topic/140425-php-mysql-address-book/#findComment-734950 Share on other sites More sharing options...
RestlessThoughts Posted January 11, 2009 Share Posted January 11, 2009 The code looks like it's all there though, just spread out over the pages. This is basically how I do links for same page changes: <tr><TD><a href = {$_SERVER['PHP_SELF']}?mode="add">Add</a></td></tr> <TR><TD><?php echo $id['name'] ?></td> <TD><a href = {$_SERVER['PHP_SELF']}?mode="edit">Edit</a></td> <TD><a href = {$_SERVER['PHP_SELF']}?mode="delete">Remove</a></td></tr> You can also direct to another page through <a href="otherpage.php"> for adding/editing/deleting if you'd like. And you might even be able to do the link just as you posted, with index.php?mode=whatever, but if you check out the last page of the tutorial you linked from you'll see about.com suggests using php_self (that way you don't have to update links if you change the webpage name). Hope that helps. Link to comment https://forums.phpfreaks.com/topic/140425-php-mysql-address-book/#findComment-734955 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.