Storing Information and displaying...

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

SquireQuack

Established Member
Impact
0
Link Program

I'm trying to create a program where anyone can enter in a Link and the link gets displayed in a page and anyone can click on it.

here's the code for the program above:
PHP:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Links</title>
</head>

<body>

<?php if (!empty($_POST['Anchor']))
echo "<a href=\"{$_POST['Anchor']}\">{$_POST['Name']}</a>" ?>

<form name="Links" action="" method="post" >
Link Location: <input name="Anchor" type="text" size="100" /> <br>
Link Name<input name="Name" type="text" size="50" /><br>
<input type="submit" value="Link it!">
</form>

</body>
</html>

I was wondering how do I do the actual storing?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Hello,

Well first lets get down what you want to store it in?

MySql or Files?

Once I get this I will assist you with creating the code.

iNod
 
0
•••
As in a Database? Google it ;)
 
0
•••
iNod said:
Hello,

Well first lets get down what you want to store it in?

MySql or Files?

Once I get this I will assist you with creating the code.

iNod

I'm just trying to make it so anyone can enter information in the textfields and a link will be created and displayed in a list. I'm wondering how do I store the information in the textbox...

I was thinking I could also write it to a file...but I think database might be the better solution.
 
0
•••
Here's something basic... I've commented throughout.. Hope you understand a tad.

PHP:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Links</title>
</head>

<body>

<form name="Links" action="" method="post" >
Link Location: <input name="Anchor" type="text" size="100" /> <br>
Link Name<input name="Name" type="text" size="50" /><br>
<input type="submit" value="Link it!">
</form>

<?php

if(!empty($_POST['Anchor']))
{

  //Connect to a database.
  //Replace dbuser, dbpass, and dbname with appropriate values
  $db = mysql_connect("localhost", "dbuser", "dbpass") or die(mysql_error());
  mysql_select_db("dbname", $db) or die(mysql_error());

  //Get the Name
  $name = $_POST['Name'];
  //Get the link
  $anchor = $_POST['Anchor'];

  //Insert the data into the database
  //This is assuming you have the table "links", with columns/fields "anchor" and "name"
  $q = mysql_query("INSERT INTO links (anchor, name) VALUES('$anchor', '$name')") or die(mysql_error());

  echo "Your link: <a href=\"$anchor\">$name</a> was successfully added.";
  //Provide a link to show all links
  echo "<br><br><a href=\"Links.php?do=show_all\">View all links</a>.";

    //If they clicked the "View all links" link
    if($do == "show_all")
    {
      $query = mysql_query("SELECT * FROM links");

      while($row = mysql_fetch_array($query))
        {
          $show = $row['anchor'];
          $show2 = $row['name'];

          echo "<a href=\"$show\">$show2</a><br>";

        }
      }
   }

?>

</body>
</html>
 
0
•••
Thanks! I appreciate the help!
 
0
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back