Brand new student, seeking PHP help. I'm using Dreamweaver 8

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
oweaponx
Forum Newbie
Posts: 2
Joined: Wed Apr 16, 2008 4:59 pm

Brand new student, seeking PHP help. I'm using Dreamweaver 8

Post by oweaponx »

Hi. I am brand new to the world of PHP. I've just gone through the basics in my class, talking about the differences between ASP, PHP (Free?), JSP, Cold Fusion (expensive?), and have been working on my first set of forms. So far, I got the basics going, and after some difficulty, got it to give a warning message, if something such as the name wasn't filled in, or if numbers weren't used in the phone number field. I'm now trying to get options I pick in a drop-down box to change the answers on my "register page."

The site is http://es5345.aisites.com/register1.html

The first is the CODE part from my register1.html page, and the second is CODE for register1.php any help, either through PHP direct, or how to fix it in Dreamweaver, is appreciated. I had tried to copy-paste what I had in my other forms, and make the needed changes through the CODE tab in Dreamweaver, but to no avail.

FYI: The only thing I need to have different responses to are based on the "location" drop-box.

-----------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Register</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-image: url(splashbackground.jpg);
}
a:link {
color: #FF0000;
}
a:visited {
color: #FFFF00;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="register1.php">
<p>&nbsp;</p>
<table width="100%" border="1">
<tr>
<td valign="top"><label>
Name*:</label></td>
<td><label>
<input name="name" type="text" id="name" />
<br />
<br />
</label></td>
</tr>
<tr>
<td valign="top"><label>Address*</label></td>
<td><label>
<input type="text" name="Address" />
<br />
<br />
</label></td>
</tr>
<tr>
<td valign="top"><label>City*:</label></td>
<td><p>
<label>
<input type="text" name="City" />
</label>
</p>
<p>&nbsp;</p></td>
</tr>
<tr>
<td valign="top"><label>State/Province*:</label></td>
<td><p>
<label>
<input type="text" name="StateORProvince" />
</label>
</p>
<p>&nbsp;</p></td>
</tr>
<tr>
<td valign="top">Zip*: </td>
<td><p>
<label>
<input type="text" name="Zip" />
</label>
</p>
<p>&nbsp;</p></td>
</tr>
<tr>
<td valign="top"><label>Country*</label></td>
<td><p>
<label>
<input type="text" name="Country" />
</label>
</p>
<p>&nbsp;</p></td>
</tr>
<tr>
<td valign="top"><label>Phone*:</label></td>
<td><p>
<label>
<input type="text" name="Phone" />
</label>
</p>
<p>&nbsp;</p></td>
</tr>
<tr>
<td valign="top"><label>Other</label>
:</td>
<td><p>
<label>
<input type="text" name="Other" />
</label>
</p>
<p>&nbsp;</p></td>
</tr>
</table>
<p>
<select name="location">
<option>Where are you located?</option>
<option>Tampa Bay</option>
<option>Florida</option>
<option>US</option>
<option>International</option>
</select>
</p>
<p>
<select name="Services" id="Services">
<option selected="selected">Services</option>
<option>Video Services</option>
<option>Web Services</option>
</select>
</p>
<p>
<select name="Payment" id="Payment">
<option>Payment</option>
<option value="Online">Online</option>
<option value="Phone">Phone</option>
<option value="Mail">Mail</option>
</select>
</p>
<p>
<input name="Register" type="submit" id="Register" onclick="MM_validateForm('name','','R','Address','','R','City','','R','StateORProvince','','R','Zip','','RisNum','Country','','R','Phone','','RisNum');return document.MM_returnValue" value="Register" />
<input type="reset" name="Reset" value="Reset" />
</p>
<p>* = Required </p>
</form>
</body>
</html>
----------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Register</title>
<style type="text/css">
<!--
body {
background-image: url(splashbackground.jpg);
}
body,td,th {
color: #FFFFFF;
}
a:link {
color: #FF0000;
}
a:visited {
color: #FFFF00;
}
-->
</style></head>

<body>
<?php

print "<p>Thank you for your information.</p>";

//Location determines when client is contacted.
if ($location == Tampa Bay) print "<p>\nWe will contact you within 1 business day.";
if ($location == Florida) print "<p>\nWe will contact you within 3 business days.";
if ($location == US) print "<p>\nWe will contact you within within 5 business days.";
if ($location == International) print "<p>\nWe will contact you within within within 10 business days.";
}
?>
</body>
</html>
------------------
:banghead: :crazy:
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Brand new student, seeking PHP help. I'm using Dreamweaver 8

Post by flying_circus »

Whats up with the little "}" guy, 4th line up from the bottom?

You tried removing him?
oweaponx
Forum Newbie
Posts: 2
Joined: Wed Apr 16, 2008 4:59 pm

Re: Brand new student, seeking PHP help. I'm using Dreamweaver 8

Post by oweaponx »

Ok. Now when I click register, instead of giving me the answers I want, I get:

Thank you for your information."; //Location determines when client is contacted. if ($location == Tampa Bay) print "

\nWe will contact you within 1 business day."; if ($location == Florida) print "

\nWe will contact you within 3 business days."; if ($location == US) print "

\nWe will contact you within within 5 business days."; if ($location == International) print "

\nWe will contact you within within within 10 business days."; ?>

:roll:

Thank you for taking time to help, and if you can help me with the problem, it will ease my day!
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Brand new student, seeking PHP help. I'm using Dreamweaver 8

Post by flying_circus »

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Register</title>
    <style type="text/css">
      <!--
        body {background-image: url(splashbackground.jpg); background-color: #000000;}
        body,td,th {color: #FFFFFF;}
        a:link {color: #FF0000;}
        a:visited {color: #FFFF00;}
      -->
    </style>
  </head>
 
  <body>
  <?php 
    # Get Post Variables
      $location = $_POST['location'];
      
    # Display Greeting
      print "<p>Thank you for your information.</p>";
  
    # Location determines when client is contacted.
      if($location == "Tampa Bay")       print "<p><br>We will contact you within 1 business day.";
      if($location == "Florida")         print "<p><br>We will contact you within 3 business days.";
      if($location == "US")              print "<p><br>We will contact you within within 5 business days.";
      if($location == "International")   print "<p><br>We will contact you within within within 10 business days.";
  ?>
  </body>
</html>
 
Post Reply