<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IT Answers &#187; `T_STRING&#8217;</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/tag/t_string/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers</link>
	<description></description>
	<lastBuildDate>Wed, 19 Jun 2013 15:50:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Is it possible to assign more than one form element to one php variable?</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/parse-error-parse-error-expecting-t_string-or-t_variable-or-t_num_string/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/parse-error-parse-error-expecting-t_string-or-t_variable-or-t_num_string/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 19:46:12 +0000</pubDate>
		<dc:creator>PatOswalt</dc:creator>
				<category><![CDATA[Array]]></category>
		<category><![CDATA[Arrays (programming)]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[Parse error]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP scripts]]></category>
		<category><![CDATA[`T_NUM_STRING']]></category>
		<category><![CDATA[`T_STRING']]></category>
		<category><![CDATA[`T_VARIABLE']]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I have an HTML form file and a PHP file that are supposed to interact with eachother to save information from the form to a contactlist text file.  I had it working fine and it has been turned it, but started playing with it and now have a question. Is it possible to assign more [...]]]></description>
				<content:encoded><![CDATA[<p>I have an HTML form file and a PHP file that are supposed to interact with eachother to save information from the form to a contactlist text file.  I had it working fine and it has been turned it, but started playing with it and now have a question.</p>
<p>Is it possible to assign more than one form element to one php variable?  I want my form to have a specific text field for the area code, the prefix and the line number and then want to combine those three field into one variable.  This is not a requirement for my class, I&#8217;m just wanting to see how much I can do with this.  Here is my html code below:</p>
<pre>
&lt;html&gt;
    &lt;!--Patricia Oswalt - IT250 Unit 4 Assignment--&gt;
    
    &lt;head&gt;
        &lt;title&gt;Telephone Directory Input&lt;/title&gt;
    &lt;/head&gt;
     
    &lt;body&gt;
        &lt;h1&gt;New Directory Listing&lt;/h1&gt;
        &lt;form action="SaveDirectory.php" method="post" enctype="application/x-www-form-urlencoded"&gt;
            &lt;p&gt;Last Name &lt;input type="text" name="LastName" size="30" tabindex="1" /&gt;
            First Name &lt;input type="text" name="FirstName" size="20" tabindex="2" /&gt;&lt;/p&gt;
            &lt;p&gt;Street Address &lt;input type="text" name="StreetAdd" size="50" tabindex="3" /&gt;&lt;/p&gt;
            &lt;p&gt;City &lt;input type="text" name="City" size="30" tabindex="4" /&gt;
            State (Abbr) &lt;input type="text" name="State" size="2" tabindex="5" /&gt;
            Zip Code&lt;input type="text" name="ZipCode" size="5" tabindex="6" /&gt;&lt;/p&gt;
            &lt;p&gt;Area Code (&lt;input type="text" name="AreaCode" size="3" tabindex="7"/&gt;)
            Phone Number &lt;input type="text" name="Prefix" size="3" tabindex="8" /&gt;-&lt;input type="text" name="LineNumber" size="4" tabindex="9" /&gt;&lt;/p&gt;
            &lt;p&gt;&lt;input type="submit" value="Save" tabindex="9" /&gt;&lt;input type="reset" tabindex="10" /&gt;&lt;/p&gt;
        &lt;/form&gt;
        &lt;p&gt;&lt;a href="InputTelephone.html"&gt;Add New Listing&lt;/a&gt;&lt;/p&gt;
        &lt;p&gt;&lt;a href="contactlist.txt"&gt;Retrieve Contact List&lt;/a&gt;&lt;/p&gt;
    &lt;/body&gt;

&lt;/html&gt;
</pre>
<p>Here is my PHP code:</p>
<pre>
&lt;html&gt;
    &lt;!--Patricia Oswalt - IT250 Unit 4 Assignment--&gt;
    
    &lt;head&gt;
        &lt;title&gt;Save Directory&lt;/title&gt;
    &lt;/head&gt;
     
    &lt;body&gt;

        &lt;?php
        
        //initializing the variables
        $LastName = ($_POST['LastName']);
        $FirstName = ($_POST['FirstName']);
        $StreetAdd = ($_POST['StreetAdd']);
        $City = ($_POST['City']);
        $State = ($_POST['State']);
        $ZipCode = ($_POST['ZipCode']);
        $AreaCode = ($_POST['AreaCode']);
        $PhoneNum = ($_POST['Prefix']['LineNumb']);
            
        //confirming that all variables will contain values
        if (empty($LastName) ||
            empty($FirstName) ||
            empty($StreetAdd) ||
            empty($City) ||
            empty($State) ||
            empty($ZipCode) ||
            empty($AreaCode) ||
            empty($PhoneNum))
            echo "&lt;p&gt;You must completely fill out the form.  Please use your browser's Back button to return to the form.&lt;/p&gt;";

        else 
        //creating, writing and saving to the text file.
        $NewContact = 'contactlist.txt';
        $Contact = fopen($NewContact, 'a+');
        $output ="n $LastName n";
        $output .="n $FirstName n";
        $output .="n $StreetAdd n";
        $output .="n $City n";
        $output .="n $State n";
        $output .="n $ZipCode n";
        $output .="n $AreaCode n";
        $output .="n $PhoneNum['Prefix']['LineNumb'] n";//this is where the error in pointing to.
        echo "New Contact Saved Successfully!";
        fwrite($Contact, $output);
        fclose($Contact);

    // Split a string into an index array
        $Contacts = "$LastName;$FirstName;$StreetAdd;$City;$State;$ZipCode;$AreaCode;$PhoneNum";
        $ContactsArray = explode(";", $Contacts);
        echo "&lt;br&gt;&lt;strong&gt;Contact List&lt;/strong&gt;&lt;br&gt;&lt;br&gt;";
        for($i=0; $i&lt;count($ContactsArray); $i++) {
             echo "$ContactsArray[$I]&lt;br&gt;";
         }
    // Sort an index array
        sort($ContactsArray);
        echo "&lt;br&gt;&lt;strong&gt;Sorted Contact List&lt;/strong&gt;&lt;br&gt;&lt;br&gt;";
        foreach($ContactsArray as $Contacts) {
           echo "$Contacts&lt;br&gt;";
         }
    
        ?&gt;

    &lt;/body&gt;

&lt;/html&gt;</pre>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/parse-error-parse-error-expecting-t_string-or-t_variable-or-t_num_string/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/9 queries in 0.014 seconds using memcached
Object Caching 324/325 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-06-19 16:11:21 -->