Jump to content

How do I turn firstname and last name to full name? *Source Attached*


Recommended Posts

Here is insertnames.php

 


<html>
<body>

<form action="insert.php" method="post">
First Name: <input type="text" name="fname" /><br><br>
Last Name: <input type="text" name="lname" /><br><br>
<input type="submit" />
</form>

</body>
</html>

 

 

Here is insert.php

 


<?php
$con = mysql_connect("localhost","crown_brownu","asdfasdf");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("crown_brownies", $con);



$sql="INSERT INTO users (fname, lname)
VALUES
('$_POST[fname]','$_POST[lname]')";

$sql="INSERT INTO users_shiping (name)
VALUES
('$_POST[name]')";




if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 user added";

mysql_close($con)
?>

 

 

My question is how do I join fname and lname to become one name so that I can import this into users_shipping under name?

 

You should keep them separate then join them on display only... but if you really want to.

$sql="INSERT INTO users_shiping (name)
VALUES
('".$_POST[lname]."', ".$_POST['fname']."')";

 

That would insert "lname, fname" into the shipping table

will it insert fname and lname in the the users_shipping table under name?

 

basically i am trying to make fname and lname (example: John Smith).  and turning those 2 values into name which would be the full name John Smith.

It worked =D but now the information in table users didn't get submitted.  Can you let me know what I am doing wrong?

 


<?php
$con = mysql_connect("localhost","crown_brownu","asdfasdf");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("crown_brownies", $con);


$password=md5($_POST[password]);
$sql="INSERT INTO users (newsletters, updates, fname, lname, login, password, company, address1, address2, city, state, province, zip, country, email, email_mode, level, phone)
VALUES
('$_POST[newsletters]','$_POST[updates]','$_POST[fname]','$_POST[lname]','$_POST[login]','$password','$_POST[company]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[province]','$_POST[zip]','$_POST[country]','$_POST[email]','$_POST[email_mode]','$_POST[level]','$_POST[phone]')";

$sql="INSERT INTO users_shipping (is_primary, name, company, address1, address2, city, state, province, zip, country)
VALUES
('$_POST[is_primary]','{$_POST[fname]} {$_POST[lname]}','$_POST[company]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[province]','$_POST[zip]','$_POST[country]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 user added";

mysql_close($con)
?>

I changed this line:

 


if (!mysql_query($sql,$sql2,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 user added";

mysql_close($con)
?>

 

would that work?  if not can you let me know what i should change.  I really don't know much about php =(



$password=md5($_POST[password]);
$sql="INSERT INTO users (newsletters, updates, fname, lname, login, password, company, address1, address2, city, state, province, zip, country, email, email_mode, level, phone)
VALUES
('$_POST[newsletters]','$_POST[updates]','$_POST[fname]','$_POST[lname]','$_POST[login]','$password','$_POST[company]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[province]','$_POST[zip]','$_POST[country]','$_POST[email]','$_POST[email_mode]','$_POST[level]','$_POST[phone]')";
$res1 = mysql_query($sql);

if (!mysql_error()) {
$sql="INSERT INTO users_shipping (is_primary, name, company, address1, address2, city, state, province, zip, country)
VALUES
('$_POST[is_primary]','{$_POST[fname]} {$_POST[lname]}','$_POST[company]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[province]','$_POST[zip]','$_POST[country]')";

$res2 = mysql_query($sql);
}
if (!mysql_error())

Thanks for all of the replys.  So i would put everything together like this?

 


<?php
$con = mysql_connect("localhost","crown_brownu","asdfasdf");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("crown_brownies", $con);


$password=md5($_POST[password]);
$sql="INSERT INTO users (newsletters, updates, fname, lname, login, password, company, address1, address2, city, state, province, zip, country, email, email_mode, level, phone)
VALUES
('$_POST[newsletters]','$_POST[updates]','$_POST[fname]','$_POST[lname]','$_POST[login]','$password','$_POST[company]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[province]','$_POST[zip]','$_POST[country]','$_POST[email]','$_POST[email_mode]','$_POST[level]','$_POST[phone]')";
$res1 = mysql_query($sql);

if (!mysql_error()) {
$sql="INSERT INTO users_shipping (is_primary, name, company, address1, address2, city, state, province, zip, country)
VALUES
('$_POST[is_primary]','{$_POST[fname]} {$_POST[lname]}','$_POST[company]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[province]','$_POST[zip]','$_POST[country]')";

$res2 = mysql_query($sql);
}
if (!mysql_error())

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 user added";

mysql_close($con)
?>


<?php
$con = mysql_connect("localhost","crown_brownu","asdfasdf");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("crown_brownies", $con);


$password=md5($_POST[password]);
$sql="INSERT INTO users (newsletters, updates, fname, lname, login, password, company, address1, address2, city, state, province, zip, country, email, email_mode, level, phone)
VALUES
('$_POST[newsletters]','$_POST[updates]','$_POST[fname]','$_POST[lname]','$_POST[login]','$password','$_POST[company]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[province]','$_POST[zip]','$_POST[country]','$_POST[email]','$_POST[email_mode]','$_POST[level]','$_POST[phone]')";
$res1 = mysql_query($sql);

if (!mysql_error()) {
$sql="INSERT INTO users_shipping (is_primary, name, company, address1, address2, city, state, province, zip, country)
VALUES
('$_POST[is_primary]','{$_POST[fname]} {$_POST[lname]}','$_POST[company]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[province]','$_POST[zip]','$_POST[country]')";

$res2 = mysql_query($sql);
}else {
  die('Error: ' . mysql_error());
}

if (!mysql_error()){

  die('Error: ' . mysql_error());
}
echo "1 user added";


?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.