copy of information
Posted: Fri Oct 20, 2006 11:09 am
Everah | Please use
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi
I am new to php and I have a very simple question.
I have created a form where the username information is entered.
At the end of the form there is a paymentname field.
I want to do this with php
if (paymentname is empty)
{
paymentname=username
}
write on the database
I have developed this code that works with the database.
thank youCode: Select all
<?php
$link = mysql_connect("localhost", "username","password");
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db("sample");
//if the username and email address are filled out
if( $_POST["emailaddress"] AND $_POST["username"])
//add the user
$Query = "INSERT INTO users VALUES ('', '".$_POST['username']."',
'".$_POST['mainStreet']."',
'".$_POST['mainCity']."',
'".$_POST['mainzipcode']."',
'".$_POST['state']."',
".$_POST['emailaddress']."',
'".$_POST['mainphonenumber']."',
'".$_POST['alternatephonenumber']."',
'".$_POST['faxnumber']."',
'".$_POST['maincontactfirstname']."',
'".$_POST['maincontactlastname']."',
'".$_POST['title']."',
'".$_POST['taxID']."',
'".$_POST['mainbillingcontact']."',
'".$_POST['paymentname']."'
)";
$Result = mysql_query( $Query );
}
?>Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]