NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Form help please.

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-12-2005, 06:27 PM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: May 2005
Location: Oklahoma City Oklahoma
Posts: 467
shanee86 is on a distinguished road
 



Form help please.


I am trying to program a script for one of my site's. It is pretty easy I guess alot would say but I am a noob at php but I am trying to learn. Anyway I own growlinks.com and I am trying to make a list of directorys were users can add they link to to help get inbound links. And well I tried to make a form and it is not working. What do I want a is a form that ads the varible $url to the database. And on the other page I am displaying the links from the database so when someone adds on it will be listed. But I can't get the form to work. Here is some code:

Directory Name:<br>
<form action="adddir.php" method="post" >
<INPUT NAME="$url" TYPE="text" size="50"><br>
<input type="submit" name="$url" value="Add">
</form>

^is the form to add the link.


<?php
$url = $_REQUEST['$url'];
mysql_connect("localhost", "edited", "edited") or die(mysql_error());
????: NamePros.com http://www.namepros.com/programming/147606-form-help-please.html
mysql_select_db("humorvid_directorys") or die(mysql_error());

// Insert a row of information into the table "directory1"
mysql_query("INSERT INTO directory1
(url) VALUES('$url')")
or die(mysql_error());

echo 'thanks';

^ is the php on adddir.php to handle the form input. But it is not adding the url to the database any ideas?


The below works and is the first attempt I made but I want a forum to do what the below does:

<?php
mysql_connect("localhost", "edited", "edited") or die(mysql_error());
echo "Connected to MySQL";
mysql_select_db("humorvid_directorys") or die(mysql_error());
echo "Connected to Database";

$id= '1';
$id1='2';
$id2='3';
$url='http://www.01webdirectory.com';
$url1='http://www.abilogic.com';
$url2='http://www.agada.info/web-directory';

echo "Table Created!";
// Insert a row of information into the table "directory1"
mysql_query("INSERT INTO directory1
(id1, url) VALUES('$id', '$url')")
or die(mysql_error());

mysql_query("INSERT INTO directory1
(id1, url) VALUES('$id1', '$url1')")
or die(mysql_error());

mysql_query("INSERT INTO directory1
(id1, url) VALUES('$id2', '$url2')")
or die(mysql_error());

echo "Data Inserted!";

?>
Last edited by shanee86; 12-12-2005 at 06:39 PM.
shanee86 is offline  
Old 12-12-2005, 06:46 PM   #2 (permalink)
NamePros Member
 
tzmartin's Avatar
Join Date: Dec 2005
Location: Missouri
Posts: 92
tzmartin is an unknown quantity at this point
 



Try this:
$url = $_POST['url'];

instead of:
$url = $_REQUEST['$url'];
tzmartin is offline  
Old 12-12-2005, 07:01 PM THREAD STARTER               #3 (permalink)
NamePros Regular
Join Date: May 2005
Location: Oklahoma City Oklahoma
Posts: 467
shanee86 is on a distinguished road
 



I changed what you said, and it didn't add it still maybe I made a mistake in the forum? I am sorry I am new to this but trying.

I think it added the entry because in phpmyadmin shows the entrys but the url column is blank.
shanee86 is offline  
Old 12-12-2005, 07:12 PM   #4 (permalink)
NamePros Member
 
tzmartin's Avatar
Join Date: Dec 2005
Location: Missouri
Posts: 92
tzmartin is an unknown quantity at this point
 



You might be able to call it without the explicit. Just use $url instead of:
$url = $_REQUEST['$url'];

This article explains more.
tzmartin is offline  
Old 12-13-2005, 08:42 AM   #5 (permalink)
Account Closed
Join Date: Dec 2005
Posts: 7
moe88 is an unknown quantity at this point
 



Hey,

First of all, change the name for your submit button, its should be somehitng else then:
<INPUT NAME="link" TYPE="text" size="50"><br>

$url = $_Post['link'];
mysql_connect("localhost", "edited", "edited") or die(mysql_error());
mysql_select_db("humorvid_directorys") or die(mysql_error());

????: NamePros.com http://www.namepros.com/showthread.php?t=147606
// Insert a row of information into the table "directory1"
mysql_query("INSERT INTO directory1 url VALUES '$url'") or die(mysql_error());

echo 'thanks';

Your errors is $_Request['$ur']; How can it request an unset variable $url?

Hope this helped!

-Moe
moe88 is offline  
Old 12-13-2005, 07:12 PM   #6 (permalink)
Senior Member
 
nasaboy007's Avatar
Join Date: Jul 2005
Location: NJ
Posts: 1,219
nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of
 



if the form is gonna use the $url variable in it, it needs to be parsed by the php, meaning that the whole form has to be "echo"ed be the php. try doing it that way and concatenating the $url where its supposed to go.
nasaboy007 is offline  
Old 12-15-2005, 03:02 PM THREAD STARTER               #7 (permalink)
NamePros Regular
Join Date: May 2005
Location: Oklahoma City Oklahoma
Posts: 467
shanee86 is on a distinguished road
 



I don't get what you mean? Sorry I am noob but I am trying to learn please show me?
shanee86 is offline  
Old 12-15-2005, 04:03 PM   #8 (permalink)
Senior Member
 
JoshHendo's Avatar
Join Date: Apr 2005
Location: Australia
Posts: 1,092
JoshHendo is a jewel in the roughJoshHendo is a jewel in the roughJoshHendo is a jewel in the rough
 



Directory Name:<br>
<form action="adddir.php" method="post" >
<INPUT NAME="$url" TYPE="text" size="50"><br>
<input type="submit" name="$url" value="Add">
</form>

Bingo, there is your problem. Remove the $ before all the names so it looks like this:
Directory Name:<br>
<form action="adddir.php" method="post" >
<INPUT NAME="url" TYPE="text" size="50"><br>
<input type="submit" name="url" value="Add">
</form>

Also, rename the submit button. It isn't good to have it the same name as something else.

Originally Posted by moe88
Your errors is $_Request['$ur']; How can it request an unset variable $url?
Err, the REQUEST line is the same as POST and GET mixed togeather. It is normally ok to use it unless you have a get variable the same as a post veriable or vica versa. Though I don't reccomend using the request variable.
????: NamePros.com http://www.namepros.com/showthread.php?t=147606

Also shane, change $url = $_REQUEST['$url']; to $url = $_REQUEST['url']; alopng with the change I said above. This should work. Never have $ within a variable name.
__________________
:bingo: :kickass: :lala: :notme: :great: :gn:
JoshHendo is offline  
Old 12-15-2005, 04:20 PM   #9 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
WHat Josh said will work, but so will this. Cleaned it up a lil

PHP Code:
Directory Name:
<br>
<form action="adddir.php" method="post">
<input name="url" type="text" size="50"><br>
<input type="submit" name="submit" value="Add">
</form>

<?php

if(isset($_POST['submit']))
{
  
$url $_POST['url'];
????: NamePros.com http://www.namepros.com/showthread.php?t=147606

  
$db mysql_connect("localhost""edited""edited") or die(mysql_error());
  
mysql_select_db("humorvid_directorys"$db) or die(mysql_error());

  
// Insert a row of information into the table "directory1"
  
$query mysql_query("INSERT INTO directory1 (url) VALUES('$url')");
  
  if(
$query)
  {
    echo 
'Thanks.';
  }
  else
  {
    die(
mysql_error());
  }
}
?>
Eric is offline  
Old 12-16-2005, 12:43 AM THREAD STARTER               #10 (permalink)
NamePros Regular
Join Date: May 2005
Location: Oklahoma City Oklahoma
Posts: 467
shanee86 is on a distinguished road
 



I have one more question this is for a different script kind of I am making it all one script but anyway I get this:

Fatal error: Call to undefined function: efine() in /home/humorvid/public_html/growlinks/mysql_connect.php on line 7

When ever I try to sign up at my site at http://growlinks.com/register.php ?

Any ideas? I check the mysql_connect.php and that efine is not on that page on that line or on that page at all any ideas?
shanee86 is offline  
Old 12-16-2005, 01:38 AM   #11 (permalink)
Domains my Dominion
 
sdsinc's Avatar
Join Date: Aug 2005
Location: Web 1.0
Posts: 9,556
sdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatness
 


Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer Animal Rescue Wildlife
Probably a typo. Should be define() instead of efine()
__________________
NameNewsletter.com - free lists of available domain names
ZoneFiles.net (beta) - ccTLD and gTLD droplists
sdsinc is offline  
Old 12-16-2005, 01:43 AM THREAD STARTER               #12 (permalink)
NamePros Regular
Join Date: May 2005
Location: Oklahoma City Oklahoma
Posts: 467
shanee86 is on a distinguished road
 



Yep I fixed it, it was a typo opps. But now I have one more question ohm I get this now when I try to register:

Fatal error: Call to undefined function: escape_data() in /home/humorvid/public_html/growlinks/register.php on line 17

I checked line 17 and here is line 17 plus the top row bottom etc:



// Check for a first name.
if (eregi ('^[[:alpha\.\' \-]{2,15}$', stripslashes(trim($_POST['first_name'])))) {
$fn = escape_data($_POST['first_name']);
} else {

Any ideas? I looked over it and didn't see why?
shanee86 is offline  
Old 12-16-2005, 05:21 AM   #13 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
As far as I know. There's no such "escape_data" function, however.... is mysql_real_escape_string() or mysql_escape_string() what you are trying to do/looking to do?
Eric is offline  
Old 12-16-2005, 04:18 PM THREAD STARTER               #14 (permalink)
NamePros Regular
Join Date: May 2005
Location: Oklahoma City Oklahoma
Posts: 467
shanee86 is on a distinguished road
 



I think it is a real funtion because I looked it up on google and found something. But I didn't right this script so I have no idea. I can post the code though one minute:

<?php # Script 13.6 - register.php
// This is the registration page for the site.

// Include the configuration file for error management and such.
require_once ('./includes/config.inc.php');

// Set the page title and include the HTML header.
$page_title = 'Register';
include ('./includes/header.html');

if (isset($_POST['submitted'])) { // Handle the form.

require_once ('mysql_connect.php'); // Connect to the database.

// Check for a first name.
if (eregi ('^[[:alpha\.\' \-]{2,15}$', stripslashes(trim($_POST['first_name'])))) {
$fn = escape_data($_POST['first_name']);
} else {
$fn = FALSE;
echo '<p><font color="red" size="+1">Please enter your first name!</font></p>';
}

// Check for a last name.
if (eregi ('^[[:alpha\.\' \-]{2,30}$', stripslashes(trim($_POST['last_name'])))) {
$ln = escape_data($_POST['last_name']);
} else {
$ln = FALSE;
echo '<p><font color="red" size="+1">Please enter your last name!</font></p>';
}

// Check for an email address.
if (eregi ('^[[:alnum][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['email'])))) {
$e = escape_data($_POST['email']);
} else {
$e = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid email address!</font></p>';
}

// Check for a password and match against the confirmed password.
if (eregi ('^[[:alnum]{4,20}$', stripslashes(trim($_POST['password1'])))) {
if ($_POST['password1'] == $_POST['password2']) {
$p = escape_data($_POST['password1']);
} else {
$p = FALSE;
echo '<p><font color="red" size="+1">Your password did not match the confirmed password!</font></p>';
}
} else {
$p = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid password!</font></p>';
}

if ($fn && $ln && $e && $p) { // If everything's OK.

// Make sure the email address is available.
$query = "SELECT user_id FROM users WHERE email='$e'";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());

if (mysql_num_rows($result) == 0) { // Available.

// Create the activation code.
$a = md5(uniqid(rand(), true));

// Add the user.
$query = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA('$p'), '$fn', '$ln', '$a', NOW() )";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());

if (mysql_affected_rows() == 1) { // If it ran OK.

// Send the email.
$body = "Thank you for registering at the User Registration site. To activate your account, please click on this link:\n\n";
$body .= "http://www.whateveraddressyouwanthere.com/activate.php?x=" . mysql_insert_id() . "&y=$a";
mail($_POST['email'], 'Registration Confirmation', $body, 'From: admin@sitename.com');

// Finish the page.
echo '<h3>Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account.</h3>';
include ('./includes/footer.html'); // Include the HTML footer.
exit();

} else { // If it did not run OK.
????: NamePros.com http://www.namepros.com/showthread.php?t=147606
echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>';
}

} else { // The email address is not available.
echo '<p><font color="red" size="+1">That email address has already been registered. If you have forgotten your password, use the link to have your password sent to you.</font></p>';
}

} else { // If one of the data tests failed.
echo '<p><font color="red" size="+1">Please try again.</font></p>';
}

mysql_close(); // Close the database connection.

} // End of the main Submit conditional.
?>

<h1>Register</h1>
<form action="register.php" method="post">
<fieldset>

<p><b>First Name:</b> <input type="text" name="first_name" size="15" maxlength="15" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></p>
????: NamePros.com http://www.namepros.com/showthread.php?t=147606

<p><b>Last Name:</b> <input type="text" name="last_name" size="30" maxlength="30" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></p>

<p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /> </p>

<p><b>Password:</b> <input type="password" name="password1" size="20" maxlength="20" /> <small>Use only letters and numbers. Must be between 4 and 20 characters long.</small></p>

<p><b>Confirm Password:</b> <input type="password" name="password2" size="20" maxlength="20" /></p>
</fieldset>

<div align="center"><input type="submit" name="submit" value="Register" /></div>
<input type="hidden" name="submitted" value="TRUE" />

</form>

<?php // Include the HTML footer.
include ('./includes/footer.html');
?>


This code came from the site of maker of the book I am learning from so I didn't right it. But any idea now the code is above.
shanee86 is offline  
Old 12-16-2005, 05:17 PM   #15 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
It's not a function. I did some searching as well. It's a custom function that the author wrote, I'd assume. /includes/config.inc.php ... If it came with a script for that. I'd venture to bet that is the file the function is in.

I found something for it, from somewhere. But basically all it is doing which pretty much does this:

PHP Code:
$variable stripslashes(mysql_real_escape_string($_POST['whatever'])); 
Heh
Last edited by SecondVersion; 12-16-2005 at 05:25 PM.
Eric is offline  
Old 12-16-2005, 05:54 PM THREAD STARTER               #16 (permalink)
NamePros Regular
Join Date: May 2005
Location: Oklahoma City Oklahoma
Posts: 467
shanee86 is on a distinguished road
 



So I should just replace that with what you put?

Dang it is changed it to what you put but the error still says the same. I don't get that. The line is changed.

This is what I changed it to below: But still same error help please.

// Check for a password and match against the confirmed password.
if (eregi ('^[[:alnum]{4,20}$', stripslashes(trim($_POST['password1'])))) {
if ($_POST['password1'] == $_POST['password2']) {
$p = stripslashes(mysql_real_escape_string($_POST['password1']));
} else {
Last edited by shanee86; 12-16-2005 at 06:05 PM.
shanee86 is offline  
Old 12-18-2005, 04:58 PM THREAD STARTER               #17 (permalink)
NamePros Regular
Join Date: May 2005
Location: Oklahoma City Oklahoma
Posts: 467
shanee86 is on a distinguished road
 



I still need help it is not fixed I added the line you told me to please help? Any ideas?
shanee86 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paypal Settlement CMachuca The Break Room 3 07-31-2004 11:14 PM
PAYPAL Litigation johnn Domain Name Discussion 6 07-31-2004 10:51 PM
Paypal Settlement Lord The Break Room 2 07-30-2004 10:30 PM
PHP Form Script, Nice 'n' Easy! OneEyedDog CODE 7 06-20-2004 04:09 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 01:17 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger