<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1001144" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1001144</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/reading-file#comment-1004991</link>
    <description> &lt;p&gt;Sorry I haven&#039;t replied earlier but just&lt;br /&gt;
wanted to say a big thanks to you guys&lt;br /&gt;
for the help - much appreciated.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Steve&lt;/p&gt;
 </description>
     <pubDate>Sat, 10 Jun 2000 19:05:00 +0000</pubDate>
 <dc:creator>myriad</dc:creator>
 <guid isPermaLink="false">comment 1004991 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/reading-file#comment-1004990</link>
    <description> &lt;p&gt;The following code should check to make sure that all fields ($name, $email, $pass) were submitted:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;code:&lt;/p&gt;
&lt;pre&gt;
if($name eq &quot;&quot; &amp;#0124; &amp;#0124; $email eq &quot;&quot; &amp;#0124; &amp;#0124; $pass eq &quot;&quot;) { #the &amp;#0124; &amp;#0124; means &#039;or&#039;
print &quot;not all required fields were filled in!&quot;;
exit; #this will stop the script from continuing and registration processes, ect
}

#put registration or whatever you want next here
[/code]

Hope that helped.  :-)

Richard

[added]
Note: in perl, there is not a space between the two piplines |, the UBB adds this so that it does not interfere with normal script operations (I guess?)
[/added]

------------------
       &lt;a href=&quot;mailto:richard@brevig.com&quot; class=&quot;bb-email&quot;&gt;richard@brevig.com&lt;/a&gt;        

I need a new signature.  :-(

[This message has been edited by richjb (edited 08 June 2000).] &lt;/pre&gt;&lt;/blockquote&gt;</description>
     <pubDate>Thu, 08 Jun 2000 15:05:00 +0000</pubDate>
 <dc:creator>richjb</dc:creator>
 <guid isPermaLink="false">comment 1004990 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/reading-file#comment-1004989</link>
    <description> &lt;p&gt;could you check a number of variables&lt;br /&gt;
at once to check whether or not information&lt;br /&gt;
has been inputed?&lt;/p&gt;
&lt;p&gt;e.g. I have a form with several input&lt;br /&gt;
boxes named name, email, phone etc.&lt;br /&gt;
I want them all to be required so instead&lt;br /&gt;
of checking them all individually to see&lt;br /&gt;
if there is an input could you do something&lt;br /&gt;
like:&lt;/p&gt;
&lt;p&gt;if $name=&quot;&quot;&lt;br /&gt;
 elseif $email=&quot;&quot;&lt;br /&gt;
 elseif $phone=&quot;&quot;&lt;br /&gt;
Sorry You&#039;ve not entered details&lt;/p&gt;
&lt;p&gt;  else&lt;br /&gt;
 continue to next part&lt;/p&gt;
&lt;p&gt;I know the above is not correct - am trying&lt;br /&gt;
to explain(badly  &lt;img src=&quot;http://www.webmaster-forums.com/ubb/smile.gif&quot; alt=&quot;&quot; class=&quot;bb-image&quot; /&gt; ) what I mean -&lt;br /&gt;
new to all this Perl !&lt;/p&gt;
&lt;p&gt;Thanks for your continued support&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Steve&lt;/p&gt;
 </description>
     <pubDate>Thu, 08 Jun 2000 14:32:00 +0000</pubDate>
 <dc:creator>myriad</dc:creator>
 <guid isPermaLink="false">comment 1004989 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/reading-file#comment-1004988</link>
    <description> &lt;p&gt;No, not using perl. You could through a JavaScript though. The &#039;if&#039; and &#039;elsif&#039; statements aren&#039;t hard...&lt;/p&gt;
&lt;p&gt;------------------&lt;br /&gt;
Critiquing over 1000 sites on the Internet today...&lt;/p&gt;
 </description>
     <pubDate>Thu, 08 Jun 2000 01:51:00 +0000</pubDate>
 <dc:creator>Justin S</dc:creator>
 <guid isPermaLink="false">comment 1004988 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/reading-file#comment-1004987</link>
    <description> &lt;p&gt;Cheers you guys!&lt;/p&gt;
&lt;p&gt;Many thanks for all your help -&lt;br /&gt;
much appreciated.&lt;/p&gt;
&lt;p&gt;Just one *little* question left -&lt;br /&gt;
Is there an easier way of making&lt;br /&gt;
a field required without having to put&lt;br /&gt;
if/elseif statements?&lt;/p&gt;
&lt;p&gt;Many thanks again.&lt;/p&gt;
&lt;p&gt;Steve&lt;/p&gt;
 </description>
     <pubDate>Thu, 08 Jun 2000 00:04:00 +0000</pubDate>
 <dc:creator>myriad</dc:creator>
 <guid isPermaLink="false">comment 1004987 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/reading-file#comment-1004986</link>
    <description> &lt;p&gt;First parse the inputted username/password.  For this example, lets say that on each line in the file, things are stored as&lt;br /&gt;
username,password,other,data&lt;/p&gt;
&lt;p&gt;($u and $p are inputed variables from the form)&lt;br /&gt;
&lt;BLOCKQUOTE&gt;code:&lt;/blockquote&gt;&lt;/p&gt;
&lt;pre&gt;
$u = &quot;rob&quot;;
$p = &quot;pasword&quot;;

open(IN,&quot;file.txt&quot;)or die &quot;Cannot open file: $!&quot;;
@data = &amp;lt;IN&amp;gt;;
close(IN);

foreach $line (@data)
{
	if( $line =~ m/^$u,$p,(.)/ )
	{
		print &quot;Found: $line&quot;;
		#The correct username and password has been inputed		
		#Insert code here to do whatever you want with the line
		exit; #Stop the script from going through the rest of the array
	}

}
[/code]

Hope that helps.


------------------
&lt;a href=&quot;http://www.thehungersite.com&quot; class=&quot;bb-url&quot;&gt;click here to help save lives&lt;/a&gt;
&lt;a href=&quot;http://www.wiredstart.com&quot; class=&quot;bb-url&quot;&gt;http://www.wiredstart.com&lt;/a&gt;  : The Technology Start Page

[This message has been edited by robp (edited 07 June 2000).] &lt;/pre&gt;</description>
     <pubDate>Wed, 07 Jun 2000 19:40:00 +0000</pubDate>
 <dc:creator>Rob Pengelly</dc:creator>
 <guid isPermaLink="false">comment 1004986 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/reading-file#comment-1004985</link>
    <description> &lt;p&gt;Ok, lets say you have used the array method. Let&#039;s also say that you have an HTML page with a field named &#039;maiden&#039; which is the field you compare to the file. Here&#039;s the code... NOTE: I&#039;ve used the array method so it can be used if there is more then one line you need to compare.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;code:&lt;/p&gt;
&lt;pre&gt;
#!/usr/bin/perl

$maidenn = &quot;Smith&quot;;

use CGI; $in = new CGI; %in = (
   maiden =&amp;gt; $in-&amp;gt;param(maiden),
);

if($in{maiden} eq $maidenn) { 
   put good page here
}
else {
   put bad page here
}

exit;
[/code]

------------------
Critiquing over 1000 sites on the Internet today... &lt;/pre&gt;&lt;/blockquote&gt;</description>
     <pubDate>Wed, 07 Jun 2000 14:23:00 +0000</pubDate>
 <dc:creator>Justin S</dc:creator>
 <guid isPermaLink="false">comment 1004985 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/reading-file#comment-1004984</link>
    <description> &lt;p&gt;Thanks for that - however  &lt;img src=&quot;http://www.webmaster-forums.com/ubb/smile.gif&quot; alt=&quot;&quot; class=&quot;bb-image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now that i&#039;ve got the information in an&lt;br /&gt;
array how do I compare it with what the&lt;br /&gt;
customer has just inputed to see if the&lt;br /&gt;
information is the same and let the&lt;br /&gt;
customer continue?&lt;/p&gt;
&lt;p&gt;many thanks for your help&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Steve&lt;/p&gt;
 </description>
     <pubDate>Wed, 07 Jun 2000 07:51:00 +0000</pubDate>
 <dc:creator>myriad</dc:creator>
 <guid isPermaLink="false">comment 1004984 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/reading-file#comment-1004983</link>
    <description> &lt;p&gt;Not 100% sure what you are asking, but I shall try.&lt;/p&gt;
&lt;p&gt;There are a few ways you can read data from the file.&lt;/p&gt;
&lt;p&gt;The first way is to reading each line 1 at a time, and place each line as an element into an @array.&lt;br /&gt;
&lt;BLOCKQUOTE&gt;code:&lt;/blockquote&gt;&lt;/p&gt;
&lt;pre&gt;
open(IN,&quot;file.txt&quot;) or die &quot;Cannot open file.txt: $!&quot;;
@data = &amp;lt;IN&amp;gt;;
close(IN);
[/code]
So now, @data would contain the lines.  The first line would be found in $data[0], second in $data[1], and so on.

You could do a foreach loop to do something with each element(line) in the array

foreach $line (@data)
{
function here
}    


The next way is to read the file into ONE $string.
&lt;BLOCKQUOTE&gt;code:&lt;pre&gt;
open(IN,&quot;file.txt&quot;) or die &quot;Cannot open file.txt: $!&quot;;
{
local $/;
$string = &amp;lt;IN&amp;gt;;
}
close(IN);
[/code]

So now $string would contain all the data inside file.txt

Hope that helps.

------------------
&lt;a href=&quot;http://www.thehungersite.com&quot; class=&quot;bb-url&quot;&gt;click here to help save lives&lt;/a&gt;
&lt;a href=&quot;http://www.wiredstart.com&quot; class=&quot;bb-url&quot;&gt;http://www.wiredstart.com&lt;/a&gt;  : The Technology Start Page &lt;/pre&gt;&lt;/blockquote&gt;&lt;/pre&gt;</description>
     <pubDate>Wed, 07 Jun 2000 02:38:00 +0000</pubDate>
 <dc:creator>Rob Pengelly</dc:creator>
 <guid isPermaLink="false">comment 1004983 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
