copy of information

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alessandra
Forum Newbie
Posts: 2
Joined: Fri Oct 20, 2006 11:00 am

copy of information

Post by alessandra »

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 you

Code: 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]
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

if(empty($payment_name))
{
   $payment_name = $username;
}
:?:
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
alessandra
Forum Newbie
Posts: 2
Joined: Fri Oct 20, 2006 11:00 am

thanks

Post by alessandra »

thanks
Post Reply