madpinchr Posted June 1, 2012 Share Posted June 1, 2012 I need a little direction. This is my goal: 1. Create a large text box that allows someone to insert links, one per line, in plain text ( ex. http://www.website.com/image.jpg 2. Save the data to a unique list saved on the server 3. Use the list to display thumbnails of all the links on a page that can be clicked to load the actual image. 4. Create a unique link so that a user can access the list at a later time. How should I go about starting this project? I have been learning some JavaScript for 3 weeks or so, but it seems that this will not work for my project? A little help? Can this be accomplished with php? What are my best options. I could really use some help. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/263505-i-need-a-little-help-with-forms/ Share on other sites More sharing options...
smoseley Posted June 2, 2012 Share Posted June 2, 2012 PHP + MySQL. You'll need a table called "links", e.g. CREATE TABLE links ( id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, uri VARCHAR(255) NOT NULL ); Then you'll need some PHP <form action="<?=$PHP_SELF?>" method="post"> <label>Enter one link per line</label> <textarea name="links"></textarea> </form> <?php if (isset($_POST["links"])) { $dbh = mysql_connect("localhost", "username", "password"); mysql_select_db("dbname"); $links = $_POST["links"]; $links = explode("\n", $links); foreach ($links as $link) { $link = mysql_real_escape_string($link); $sql = "INSERT INTO links (uri) VALUES('{$link}')"; mysql_query($sql, $dbh); } } ?> And finally, you'll need a page to display your links: <ul> <?php $dbh = mysql_connect("localhost", "username", "password"); mysql_select_db("dbname"); $sql = "SELECT * FROM links"; $result = mysql_query($sql, $dbh) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { ?> <li><a href="<?=$result["link"]?>" target="_blank"><?=$result["link"]?></a></li> <?php } ?> </ul> Quote Link to comment https://forums.phpfreaks.com/topic/263505-i-need-a-little-help-with-forms/#findComment-1350496 Share on other sites More sharing options...
madpinchr Posted June 2, 2012 Author Share Posted June 2, 2012 Thank you so much for your help! Quote Link to comment https://forums.phpfreaks.com/topic/263505-i-need-a-little-help-with-forms/#findComment-1350616 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.