Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array email selection? 1

Status
Not open for further replies.

MAWarGod

Programmer
Feb 15, 2002
352
US
Hello I have a array I made in My CMS lang file that looks like this

$lang['easy_email_signups'] = array(
'' => 'F',
'@hotmail.com' => 'Yahoo',
'@yahoo.com' => 'TracFone',
'@aol.com' => 'AOL',
'@live.com' => 'Windowslive',
);

ok in the tpl file I have
<input class="textinput" maxlength="255" name="txtemail" size="40" value="{$smarty.session.email}" />
now I want to add this so the user inputs thier msn or yahoo user name and the rest is added on selection.
<select class="select" style="width: 150px;" name="txtemail">
{html_options options=$lang.easy_email_signups selected='F'}
</select>

I guess My question is how to go about this?? do I asign a string value to the input?
I am not sure how to form it so if the user types in say.. (Myusername) it is sudmitted as Myusername@hotmail.com if the hotmail was the selection..
can some please help point me into the right direction here?

Thank you before hand..

MA WarGod

I believe if someone can think it, it can be programmed
 
You would have to concatenate the values from both inputs.

You could do it in JS and assign it to a hidden form field once the email service is selected, or do it in PHP using the values of the $_POST['select'] and $_POST['txtemail'] variables (assuming your form is being submitted via POST), of course after having cleansed them properly.

NOTE you can't give them both th same name. So change one to something else.

Code:
$completeEmail=$_POST['txtemail']. $_POST['selectName']



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
ok and if its inputing it to db like this?

Code:
$_SESSION['email'] = $email = isset($_POST[ 'txtemail' ])?strip_tags(trim($_POST[ 'txtemail' ])):'';

so I gather its using the smarty code
Code:
value="{$smarty.session.email}"

So I named the second one
Code:
<select class="select" style="width: 150px;" name="selectName" value="{$smarty.session.selectName}>

and tested to see it it passed the value like this
Code:
$_SESSION['selectName'] = $email = isset($_POST[ 'selectName' ])?strip_tags(trim($_POST[ 'selectName' ])):'';

so both parts pass to db, Ok now My question is how do I put these together, or combin these sessions?

so Myusername@hotmail.com inputs to db?



MA WarGod

I believe if someone can think it, it can be programmed
 
Like I showed you above: Concatenate both parts together.

Code:
$completeEmail=$_POST['txtemail']. $_POST['selectName']

The $completeEmail variable will hold the entire email as Myusername@hotmail.com

You can take that and plug it into your DB insert statement.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Vacunita does it matter that I am passing between two php files? from signup to savesignup?

the input value is on signup.php this line is in savesignup.php

Code:
$_SESSION['email'] = $email = isset($_POST[ 'txtemail' ])?strip_tags(trim($_POST[ 'txtemail' ])):'';

I played with this for hours and can't get it to input in the db as Myusername@hotmail.com


MA WarGod

I believe if someone can think it, it can be programmed
 
Yes, it matters, because the $_POST vars will then be empty in the second page.

In which case you would want to use your $_SESSION variables.

$fullEmail=$_SESSION['email'] . $_SESSION['selectName'];

Just use the appropriate variables to concatenate, you are already doing the rest.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
ok so if I am follow you correctly I place

Code:
 $fullEmail=$_SESSION['email'] . $_SESSION['selectName'];
in savesignup.php

So $fullEmail becomes populated as it says the full email..

then insert $fullEmail in db? sorry I am losted I'll admit it!!

I can not figure out how to form this, although I think I understand the statments I have been trying to form it most of the day and last night.. knowing abit about perl I am still a novice in php


MA WarGod

I believe if someone can think it, it can be programmed
 
$fullEmail now has your complete email address. You can take that and plug it into your DB insert query whatever that is. There is no more or me to tell you.Use the variable in your query.

Something like this for instance:

Code:
$sql="INSERT INTO tablename (fieldname1, fieldname2, emailDBfield, fieldname3...) VALUES('xxx','xxx',[red]$fullEmail[/red],'xxx',...);

$res=mysql_query($sql);

...

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
ok see I was trying it like this

Code:
$fullEmail = $_SESSION['email'] . $_SESSION['selectName'];

$sql->query ( "INSERT INTO !
				(
				active,
				username,
				password,
				lastvisit,
				regdate,
				level,
				timezone,
				allow_viewonline,
				rank,
				email,
				country,
				actkey,
				firstname,
				lastname,
				gender,
				lookgender,
				lookagestart,
				lookageend,
				lookcountry,
				address_line1,
				address_line2,
				state_province,
				county,
				city,
				zip,
				lookstate_province,
				lookcounty,
				lookcity,
				lookzip,
				lookradius,
				radiustype,
				birth_date,
				status,
				about_me,
				couple_usernames,
				zip_latitude,
				zip_longitude,
				levelend,
				regIP)
		 VALUES (  ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array( USER_TABLE, $active, $username, md5( $password ), $lastvisit, $regdate, $level, $timezone, $viewonline, $rank, $fullEmail, $from, $actkey, $firstname, $lastname, $gender, $lookgender, $lookagestart, $lookageend, $lookfrom, $address1, $address2, $stateprovince, $county, $city, $zip, $lookstateprovince, $lookcounty, $lookcity, $lookzip, $lookradius, $radiustype, $birthdate, $status,  $about_me, $couple_usernames,  $ziprec['latitude'], $ziprec['longitude'], $levelend, $regIP ) );

but I get a blank in db for email..

MA WarGod

I believe if someone can think it, it can be programmed
 
ok I think I got it

Code:
$fullEmail=$_SESSION['email']. $_SESSION['selectName'];

$email = $_POST['txtemail']. $_POST['selectName'];

then the array insert

using $email, in the array

Phil AKA Vacunita I want to thank You for helping Me learn..
and I hope many come across this thread and give you stars!!
as I feel You have helped Me alot!! and if I could reward that more I would.....

Thank You again
I wish you well
Robert

MA WarGod

I believe if someone can think it, it can be programmed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top