Beginner at php

Discussion in 'Programming' started by suze, Mar 16, 2008.

  1. #1
    With your help I was able to get through the exersize that I was worked on. Now I am trying to take it to a real page and I am having trouble figuring out what is necessary for my page. And I think that I need to do something to protect all the boxes that have optional answers, but I am not sure what.
    Depending on where I put the curly brackets my error is jumping between the end of the document and line 51.

    <?php

    // mail processing script
    // remove escape characters from POST array
    if (get_magic_quotes_gpc()) {
    function stripslashes_deep($value) {
    $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
    return $value;
    }
    $_POST = array_map('stripslashes_deep', $_POST);
    }
    //validate the input, beginning with name
    $name = trim($_POST['name']);
    if (empty($name)) {
    $error['name'] = 'Please Enter Your Name';
    }

    $email = $_POST['email'];
    // check for valid email address
    $pattern = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
    if (!preg_match($pattern, trim($email))) {
    $error['email'] = 'Please enter a valid email address';
    }


    // initialize variables
    $to = 'ddsuze@shaw.ca'; //use your own email address
    $subject = 'Feedback form East - West Seasons';



    //build the message
    $message = 'On '.date('l, M j, Y').' at '.date('g:ia').',';
    $message .= "$name ($email) wrote: \n\n";


    //build the additional headers
    $additionalHeaders = "From: Eagle Real Estate Investments Ltd.<thuseenterprises@gmail.com>\r\n";
    $additionalHeaders .= "Reply-To: $email";


    //send the email if there are no errors
    if (!isset($error)) {
    $mailSent = mail($to, $subject, $message, $additionalHeaders);

    //check that the mail was sent successfully
    if (!$mailSent) {
    $error['notSent'] = 'Sorry, there was a problem sendng your mail. Please try again later.';
    }
    }
    ?>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"lang="en" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Eagle Real Estate Investments</title>
    <link href="ereil.css" rel="stylesheet" type="text/css"/>
    <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>

    <div id="rightbanner">
    <p class="realestatelogo">
    <img src="images/realestatelogo.gif" alt="Eagle Real Estate Investments Ltd"/>
    </p>
    </div>


    <div id="leftbanner">
    <p class="eaglelogo">
    <img src="images/eaglelogo.gif" alt="Eagle Real Estate Investments Ltd. Logo"/>
    </p>
    </div>

    <div id="leftside3">
    <p class="p_sidebar">
    <a href="index.php">Home</a><br/>
    <a href="investint.php">Investor Interest</a><br/>
    <a href="alberta.php">Why Alberta?</a><br/>
    <a href="edmonton.php">Why Edmonton?</a><br/>
    </p>
    </div>



    <div id="centercolumn2">
    <h3>Investor Interest Questionaire</h3>


    <?php if (!$mailSent) { ?>

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name= "contactForm" id="contactForm" onsubmit="MM_validateForm('name','','R','email','','RisEmail','message','','R');return document.MM_returnValue">

    <p>
    <label for="name">Name:</label><?php if (isset($error['name'])) { ?>
    <span class="warning"><?php echo $error['name']; ?></span>
    <?php } ?>
    <br />
    <input type="text" name="name" id="name"
    <?php if(isset($error)) {echo "value='$name'";} ?> />
    </p>


    <p>
    <label for="address">Address:</label><br/>
    <input type="text" name="address" id="address" />
    </p>

    <table>
    <tr>
    <td><label for="city">City:</label><br/>
    <input type="text" name="city" id="city" /></td>

    <td><label for="province">Province:</label><br/>
    <input type="text" name="province" id="province" /></td>

    <td><label for="postalcode">Postal Code:</label><br/>
    <input type="text" name="postalcode" id="postalcode" /></td>
    </tr>
    </table>

    <p>
    <label for="email">Email:</label><?php if (isset($error['email'])) { ?>
    <span class="warning"><?php echo $error['email']; ?></span>
    <?php } ?>
    <br />
    <input type="text" name="email" id="email"
    <?php if(isset($error)) {echo "value='$email'";} ?> />
    </p>

    <p>
    <label for="currentemployment">Current Employment:</label><br/>
    <input type="text" name="currentemployment" id="currentemployment" />
    </p>

    <p>
    <label for="ownhome">Do you own your own home?</label><br/>
    <input type="text" name="ownhome" id="ownhome" />
    </p>

    <p>
    <label for="equity">Equity? $</label><br/>
    <input type="text" name="equity" id="equity" />
    </p>

    <p>
    <label for="value">Current Value of RSP's?</label><br/>
    <input type="text" name="value" id="value" />
    </p>

    <p>
    Happy with Current Return? <br/>
    Yes<input type="radio" name="happy" value="yes" />
    No<input type="radio" name="happy" value="no" />
    </p>


    <p>
    <span class="bold">Please provide responses to the following questions as
    openly and freely as you are able. This will provide the framework for
    determining how compatible you are with our investing programs and which
    of those programs best suits your situation.</span>
    </p>

    <p>1. If we were meeting five years from today and you were looking back
    over those five years, what must have happened both personally and professioally,
    for you to feel contedted today with your progress?
    </p>

    <p>
    <label for="one"></label>
    <textarea name="one" id="one" cols="60" rows="4"></textarea>
    </p>

    <p>
    2. What first hand Real Estate related experience do you have already?
    Have you participated in the market? What aspects of it? And what size of
    deals have you been involved in?
    </p>

    <p>
    <label for="two"></label>
    <textarea name="two" id="two" cols="60" rows="4"></textarea>
    </p>


    <p>
    3. How 'hands on' do you wish to be with the investment? What decisions do
    you want to be a part of?
    </p>

    <ul>
    <li>
    Purchase decisions-
    Yes<input type="radio" name="purchase" value="yes" />
    No<input type="radio" name="purchase" value="no" /><br/>
    </li>

    <li>
    Financing decisions-
    Yes<input type="radio" name="finance" value="yes" />
    No<input type="radio" name="finance" value="no" /><br/>
    </li>

    <li>Property Management decisions-
    Yes<input type="radio" name="property" value="yes" />
    No<input type="radio" name="property" value="no" /><br/>
    </li>

    </ul>

    <p>
    <label for="three"></label>
    <textarea name="three" id="three" cols="60" rows="4"></textarea>
    </p>



    <p>4. What is your primary focus in investing? Are you an 'Active' or
    'Passive' investor? An active investor is involved on a daily basis on all
    decisions respecting the property. A passive investor simply requires a
    good return on the investment, while someone elsee manages the problems.
    </p>

    <p>
    Active<input type="radio" name="four" value="active" />
    Passive<input type="radio" name="property" value="passive" />
    </p>


    <p>
    5. What returns are you seeking?</p>
    <p>
    <label for="five"></label>
    <textarea name="five" id="five" cols="60" rows="4"></textarea>
    </p>

    <p>
    6. How soon do you need to realize those returns?</p>
    <p>
    <label for="six"></label>
    <textarea name="six" id="six" cols="60" rows="4"></textarea>
    </p>


    <p>
    7. What, if any are your expations for monthly cash flow?
    </p>
    <p>
    <label for="seven"></label>
    <textarea name="seven" id="seven" cols="60" rows="4"></textarea>
    </p>
    <p>8. What financial resources do you bring to the table? How much money
    can you invest in a single project and what is your total investment capability?</p>
    <p>
    <label for="eight"></label>
    <textarea name="eight" id="eight" cols="60" rows="4"></textarea>
    </p>


    <p>
    9. Are the funds you are using cash or borrowed? On borrowed funds,
    financial institutions require personal quarantees. Are you prepared to
    sign a personal quarantee?</p>
    <p>
    <label for="nine"></label>
    <textarea name="nine" id="nine" cols="60" rows="4"></textarea>
    </p>


    <p>
    10. How available are your investment resources? Are they readily available or,
    if not, how much notice will you require to access funds? </p>
    <p>
    <label for="ten"></label>
    <textarea name="ten" id="ten" cols="60" rows="4"></textarea>
    </p>


    <p>
    11. Is there someone in your life who will be participating in your decisions
    related to investments, and do you expect that person to be named as a
    benificiary of the investment?
    </p>
    <p>
    <label for="eleven"></label>
    <textarea name="eleven" id="eleven" cols="60" rows="4"></textarea>
    </p>


    <p>
    12. What is your personal risk tolerance on a scale of 1-10? 1- No Risk 10- Extreme
    Risk
    </p>
    <p>
    <label for="twelve"></label>
    <textarea name="twelve" id="twelve" cols="60" rows="4"></textarea>
    </p>


    <p>
    13. Are you prepared to take action? Or just wanting information?
    </p>
    <p>
    <label for="thirteen"></label>
    <textarea name="thirteen" id="thirteen" cols="60" rows="4"></textarea>
    </p>


    <p>
    14. Do you know anyone else that may be interested in investing?
    </p>
    <p>
    <label for="fourteen"></label>
    <textarea name="fourteen" id="fourteen" cols="60" rows="4"></textarea>
    </p>


    <p>
    15. Do you own any other investments, if so what does your portfolio consist of?
    </p>
    <p>
    <label for="fifteen"></label>
    <textarea name="fifteen" id="fifteen" cols="60" rows="4"></textarea>
    </p>


    <p>
    <input name="ewComments" type="submit" id="ewComments" value="Submit" />
    </p>





    </div>




    <div id="footer3">
    <p class="center">
    site created by sjm design
    </p>
    </div>

    </body>
    </html>
     
    suze, Mar 16, 2008 IP
  2. 9450184

    9450184 Peon

    Messages:
    30
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you add one more } in the last php thing, like

    <?php if(isset($error)) {echo "value='$email'";}} ?>
    Code (markup):
    it won't error out :D
    But I am not sure if it will work correctly :p I didn't test :)
     
    9450184, Mar 17, 2008 IP
  3. suze

    suze Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks that fixed the error that I could not find. I have a few more issues to work on but I was able to get the form to send me an email.

    Thanks again

    Suze
     
    suze, Mar 17, 2008 IP
  4. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #4
    thats sorta an anal looking mail script .. you can make them much easier and much more comprehensive to humans :)
     
    ezprint2008, Mar 18, 2008 IP