Announcement

Collapse
No announcement yet.

Idiots guide to PHP utilisation - as i get it wrong

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Idiots guide to PHP utilisation - as i get it wrong

    Hi All

    I apologise if I come across slow at times - im fairly new to Actinic - especially Developement so your patients would be appreciated .

    I have found that the functionality of PHP is restricted but was trying to work out the best way of incorporating a Object Script.

    I have searched but i get an error on one of the lines when I have passed through in the way that I would have expected.


    But i keep getting...
    Parse error: syntax error, unexpected ':' in main on line 50

    The script is below
    Code:
    <?php
    //
    //	Config
    //
    require('config.php');
    
    $sucsess = false;
    //
    //	Has the Submit button been pressed?
    //
    if( isset($_POST['Submit']))
    {
    	$error = false;
    //
    //	Get data
    //
    	$name = trim(htmlspecialchars($_POST['name']));
    	$email = trim(htmlspecialchars($_POST['email']));
    	$address = trim(htmlspecialchars($_POST['address']));
    	$domain = trim(substr(stristr($email, "@"), 1));
    //
    //	1st Parse (easy)
    //
    	if(strlen($name) < 5)
    	{
    		echo('<span class="style11">You MUST enter your NAME...<br /></span>');
    		$error = true;
    	}
    	if(strlen($email) < 9)
    	{
    		echo('<span class="style11">You MUST enter your EMAIL...<br /></span>');
    		$error = true;
    	}
    	if(strlen($address) < 15)
    	{
    		echo('<span class="style11">You MUST enter your ADDRESS...<br /></span>');
    		$error = true;
    	}
    //
    //	Everything is OK..! 2nd Parse...!
    //	
    	if($error == false)
    	{
    		$hosts = gethostbynamel($domain);
    		$mx = array ();
    		
    		if (!getmxrr($domain, $mx))
    		{
    			$error = true;
    			echo('<span class="style11">ERROR Checking DOMAIN '.$domain.'...'.$hosts[0].'<br /></span>');
    		}
    //
    //	Finally
    //		
    		if($error == false)
    		{
    			$sucsess = true;
    		}
    	}
    }
    else
    {
    	$name = '';
    	$email = '';
    	$address = '';
    }
    //
    //	Put the Form on the Page and fill in...
    //
    if($sucsess == false)
    {
    echo('
    		<table width="100%" border="0">
              <tr>
                <td width="26%" align="right" valign="middle">Name:</td>
                <td width="38%" align="left" valign="bottom">&nbsp;
                <input name="name" type="text" value="'.$name.'" size="45" /></td>
                <td width="36%" rowspan="5" align="center"><img src="../images/ramb.jpg" alt="Ramblers" width="342" height="235" /></td>
              </tr>
              <tr>
                <td align="right" valign="middle">E-Mail: </td>
                <td align="left">&nbsp;
                <input name="email" type="text" value="'.$email.'" size="45" /></td>
              </tr>
              <tr>
                <td align="right" valign="middle">Address:</td>
                <td align="left">&nbsp; <textarea name="address" cols="40" rows="5" />'.$address.'</textarea></td>
              </tr>
              <tr>
                <td rowspan="2" align="left" valign="bottom">&nbsp;</td>
                <td align="left" valign="bottom">&nbsp;
                <input type="submit" name="Submit" value="Submit"></td>
              </tr>
              <tr>
                <td align="left" valign="bottom">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="3" align="left" valign="bottom">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="3" align="left" valign="bottom">Entry to this competition is FREE. <br />
    			The closing date for the competition is 30th June 2008 and the winner who will be drawn at random will be notified within 28 days of this date.
    <br/>
    By providing your name, postal address and email address you are agreeing to subscribe to the Outdoors.co.uk newsletters and receive communications. <br />Your details will be held by Outdoors and passed to Ramblers Worldwide Holidays only.
    <br />
    Entrants must be over 18 years of age.</td>
              </tr>
            </table>
    ');
    }
    else
    {
    	$message = $email . " thank you for your entry to the 'Outdoors/Ramblers Holiday' Competition, your details have been recorded\n\n" . $name . "\n". $address . "\n\n";
    	$headers  = 'MIME-Version: 1.0' . "\r\n";
    	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    	
    	$headers = "From: ".$email."\r\nCc:".$email."\r\nReturn-Path: enquiries@outdoors.co.uk";
    
    	mail("enquiries@outdoors.co.uk", "Outdoors Competition", $message, $headers);
    	mail("outdoors-join@outdoors.co.uk", "Outdoors Mailing List", $message);
    		
    	$link = @mysql_connect('localhost', $dbuser, $dbpass);
    	if ($link)
    	{
    		$sql = "INSERT INTO competition (name, email, address) VALUES ('".$name."', '".$email."', '".$address."')";
    			
    		@mysql_select_db($db_name, $link);
    		mysql_query($sql);
    		mysql_close($link);
    	}
    			
    	echo("<br><br><center><h2>Thank you for your entry " . $name . "</h></center>");
    
    }
    //
    //	End php
    //
    ?>

    And for the config.php file - content...
    Code:
    <?php
    
    $db_name = 'user';
    $dbpass = 'relevant password';
    $dbuser = 'user';
    
    ?>

    Any help muchly appreciated as i have obviously missed w=something or it is possible that this just won't work

    #2
    No doctors here Dave, you got the right forum dude?

    Comment


      #3
      ah haha - you got me - my spilleng tis not some good

      Comment


        #4
        You will need Norm or Gabe for this one as they're the php dudes. I did notice your table coding looks a little off, be careful on your <td> counts on each row, however that will not be causing the error you are getting. I'm learning php at the mo, but buggered if i can see the problem, you haven't made any of the silly mistakes I always do.

        PS - nice to see a sense of humour, it will serve you well on here, welcome to the forum.

        Comment


          #5
          Thanks Lee - what humor?

          I have tested the script outside of Actinic and it works so I am hopefull - just not sure if it will in Actinic

          Comment


            #6
            Have you got encoding="perl" and selectable="false" added and are you running it within a block?

            Comment


              #7
              encoding="perl" - not tried...

              selectable="false"
              block php='true'

              Comment


                #8
                oop! i think you might ahve the wrong end of this very complicated stick.

                you're trying to include database variables, in a page that will be flat, when they reach the web.

                actinic's internal php turns itself into flat html. you'll have to put this script online. and call it from a template.

                alternatively, you can add your details into a file called 'actinic_main.php' located in your actinic install folder. these will be included into the php engine when actinic starts. this till wont help you, if you're trying to get actinic to do complicated things offline.

                Comment


                  #9
                  thanks gabe - just think of me as very simple when i ask...
                  um.... how?

                  Comment


                    #10
                    put your script online and make it work.

                    use the form part in actinic.

                    make a fragment, and inside !!< html here >!! tagging, put your submission form.

                    then link to your script, using the action attribute of your form.

                    <form action="path/to/script.php">

                    since your script produces a response, it might be wise to call this from a javascript popup window. that way, your response will be contained. and you can let the user cross of the popup when thay are done.

                    Comment


                      #11
                      that sounds do-able

                      thanks Gabe

                      i'll feedback

                      Comment


                        #12
                        and for gods sake man, dont use a break inside a message span.

                        pointless breaks make baby jesus cry.

                        Comment


                          #13
                          dont screem and don't cry with pity...

                          im too in experienced to make this work

                          Comment


                            #14
                            no its no good - i was looking over this again last night ad this morning but if possible is there a step by step available?

                            PLEASE PLEASE PLEASE

                            Comment


                              #15
                              yes, try this tutorial.

                              Sadly, there are not step by step instructions for a piece of custom work like the one your attempting.

                              your only recourse is to learn how it works and knuckle down, or pay someone to do it.

                              Comment

                              Working...
                              X