...

View Full Version : Form As Variable



GSimpson
08-23-2006, 07:52 AM
Ok so,
I have a script that inserts a variable into the database,
so how do i make my form my variable,
i know that with js its like this:
var name=document.formname.inputname.value;

is this a legal php one?

$name=doument.formname.inputname.value;

thanks

NancyJ
08-23-2006, 09:30 AM
The form has to be submitted to a php script but then it would be accessed like


<?
$name = $_POST['inputname'];
//or $_GET if form method is get instead of post
?>

GSimpson
08-23-2006, 11:12 AM
thanks!!! however, I have encountered another problem, now this is a bit off topic but i want to send a variable to a table. will this work?


<?php
//records username and password into database
$username=$_POST["username"];
$password=$_POST["password"];
$con = mysql_connect("mysql2.freehostia.com","glysim_userpass","******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("glysim_userpass", $con);

mysql_query("INSERT INTO usernames (username, password)
VALUES ($username, $password)");
mysql_close($con);
?>

thanks again

GSimpson
08-24-2006, 02:46 AM
C'mon!!!!

Fumigator
08-24-2006, 05:31 AM
Instead of asking us if it will work, why not just try it and see?

Len Whistler
08-24-2006, 06:07 AM
Below is what I use. It's a quick cut and paste but easy to figure out, I'm sure there is other variations that will also work.



mysql_query("INSERT INTO canadastore (item_catagory, item_image,
item_title, item_description, item_price, item_location, item_email, item_date)
VALUES ('$_POST[catagory]', '$_POST[date_image]', '$_POST[item_title]',
'$_POST[item_description]', '$_POST[item_price]', '$_POST[item_location]',
'$_POST[item_email]', '$_POST[item_date]') ")
or die(mysql_error());

GSimpson
08-24-2006, 08:19 AM
Thanks for everyones input, but now i'm finished.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum