Jump to content

Drongo_III

Members
  • Posts

    579
  • Joined

  • Last visited

Posts posted by Drongo_III

  1. Hi Guys

     

    I was trying to set a class property today in the same way I have for a long time but it didn't work and it made me wonder whether I have been doing something wrong for a while.

     

    When i try to set a session variable to a property of the class, as in $sessID below, i get a php error: "unexpected t_variable".  I have been staring at the screen for some hours but I cant actually see anything wrong with the line.

     

    If I comment out the  sessID line and instead set this property  in the construct this works fine.  So few questions spring to mind:

     

    1) is there some reason you can't set a variable outside of the construct like this?

    2) is it best practice to set such variables as part of the construct?

    3) Why do all the other variables work fine but not the session one?

     

    It may yet transpire the answer to one of these questions is the answer to all :)

     

    Thanks,

     

    Drongo

    class user_admin extends login {
    	
    		public $errors = array();
    		private $userData = array();
    		private $changePassword = false;
                    public $sessID = $_SESSION['user_logged'];
    		
    
    		public function __construct(){
    		
    			//$this->sessID = $_SESSION['user_logged'];
    				
    			$this->getUserData();
    			include('/forms/user-admin.php');
    		
    		}
    }
    
  2.  

    You need to use the second parameter to give the file an alternate name or else the file will be added with the full linux path and won't unzip on windoze:

    $zip->addFile('../fileUploadLocation/somefolder/image1.jpeg', 'image1.jpeg');
    //or maybe this for a subdir
    $zip->addFile('../fileUploadLocation/somefolder/image1.jpeg', 'somefolder/image1.jpeg');

     

     

    Thanks Abra!

     

    I will try this tomorrow. See i knew one of clever peeps here would have it down :)

     

    Drongo

  3. Hi Guys

     

    This is a bit of a weird one and I wondered if perhaps someone here had experienced this and found a work around.

     

    I'm using zip archive on a project at the moment. Basic version of the code is below.

     

    When I zip a file and output it to the browser using headers it works fine in the example below. BUT if I try to add a file from another directory, as in the commented out line below, the resulting zipped folder can't be unzipped in windows. When I try I get a "The folder XXXX is invalid" message.

     

    I sent the same zipped folder to my htc phone and it opened the zipped folder no problem.

     

    The puzzling thing about windows is that it works fine if the image originates in the same directory as the executing script and can be opened no problem.

     

    So is this something anyone else has encountered? And how can you get around it?

    $zip = new ZipArchive();
                    if ($zip->open('./test2.zip',ZipArchive::CREATE) === TRUE) {
                                   
                                  //$zip->addFile('../fileUploadLocation/somefolder/image1.jpeg');
                                    $zip->addFile('image3.jpeg');
                                    $zip->close();
                                    echo 'ok';
                    } else {
                                    echo 'failed';
    }
    
  4. Hi Guys

     

    Working on a big multi-stage form.

     

    The form has multiple stages, each posting to the next.

     

    There is currently minimal validation -  validation is done via a simple regex  which as a minimum allows these chars:  a-z A-Z 0-9 - £

     

    As I need to store up all the user data until they complete and it can be passed to the database I am wondering if there is anything in particular I should do, besides the validation, to make sure the data being held in the session is safe?  I've read about some exploits via user data in the session but can't say I have an exhaustive understanding of this so any tips are welcome.

     

    Drongo

  5. Sry tried to respond to this post but its not saving my code in the code block. Might be because the line length of the regex I am trying to paste in. :/

     

    I know this is frowned upon but going to try and paste this straight into the message window:

     

    <?php

    $STRING = 'This is a https://www.google.com link';
     
    $linkReplace = "<a href=" . "$1" . " target='_blank'>$1</a>"; // Replacement pattern to create a link
     
    $text  = preg_replace($RegExp, $linkReplace , $STRING);
     
    echo $text;
  6. Hi Guys

     

    Bit of an odd one. I've created a custom 500 error page and my hosting company has told me that they've made the necessary httpd.conf changes.

     

    The thing is - how do you simulate a 500 server errror?

     

    I've tried throwing an exception but this did nothing. I've also tried breaking a htaccess file but this doesnt display my custom page, which leads me to think that the configuration hasn't been setup properly. But as I'm not sure if this is a valid way to test it I thought I would get some advice.

     

    Any helo would be appreciated!

     

    Drongo

  7. Most likely you tried to call the getElementById before the page loads or before the element is on the page.

     

     

    Perhaps you can point out where i'm doing it wrong?  The below code doesn't work. 

    <!doctype html>
    <html>
    <head>
    	
    	<script type="text/javascript">
    	
    		var mylink;
    		
    		function init(){
    		
    			mylink = document.getElementById('link1');
    			alert(mylink.id);
    			myLink.onclick = myFunc;
    		}
    		
    		function myFunc(){
    		
    			alert('click worked');
    		}
    				
    	</script>
    
    	
    
    </head>
    
    <body onload="init();">
    
    	<a href="#" id="link1">Click me</a>
    	
    	
    </body>
    </html>
    

    But if I replace that init function with a direct call to document.getElement (as per below) it works fine. So I am just trying to understand either what I am doing wrong or whether there is some fundamental precept of javascript i am missing (probable)...

     

    
    		function init(){
    		
    			//mylink = document.getElementById('link1');
    			//alert(mylink.id);
    			document.getElementById('link1').onclick = myFunc;
    		}
    

     

     

     

    And thanks for this mate but this is a different type of event registration. I am trying to work out why the traditional model doesnt seem to work for me

  8. This should work.

    http://jsfiddle.net/6eJuB/

     

    window.document.querySelector("#elmId").addEventListener("click", myFunc, false);

     

     

    Thanks for that. But it wasn;t so much that I couldnt get the event to work, or that I couldn't register the event in another way. What I was driving at is to try and understand why it works with document.getElementById but not when I simply use a resource (i.e. set a var with document.getElement... and then assign it to the event). Any ideas why that may be?

  9. Hello, I have a script that displays data from a XML file into a table and it works great. What I want to do is try to set a background color to a table cell based on the report element it gets from the XML file. I have another script I have done this for and it works great. For some reason I can't seem to get it working with this script.

     

    Here is a working page of what it should look like. If you look below the map the tables have different backgrounds depending on the report.

     

    http://www.mesquiteweather.net/wxsvr.php

     

     

    Here is the actual page I am trying to get it to work on and the code I am using below.

     

    http://www.mesquiteweather.net/wxspotter.php

    <?php
    #######################################################################################
    #
    #  SPOTTER NETWORK STORM REPORTS
    #  version 1.00
    #
    #  This program is free and no license is required.
    #
    #
    #  mesquiteweather.net
    #
    #######################################################################################
    
    ////  SETTINGS  ////
    
    
    ////  SETTINGS  ////
    
    $bkgColor                                       = '#d4d4d4';  // Background color   Examples:  "gray"  "#CCC"   "#CCCCCC"
    $bc                                             = '#EEEEEE';  // Background color of table cells
    $dtColor                                        = '#FFF';     // Date & time color  Examples:   "#FC0"   "#FFCC00"   "white"
    $width                                          = '100%';     // Set the width of the report tables
    
    ////  END OF SETTINGS  ////
    
    
    #######################################################################################
    
    ini_set('display_errors','1');
    
    ## Start Configurable data ##
    
    //Set path to data file
    $data = "http://www.spotternetwork.org/data.php";
    
    ## End Configurable data ##
    
    // overrides from the Carter Lake Settings.php file (if applicable)
    global $SITE;
    if(isset($SITE['cacheFileDir'])) {$cacheFileDir = $SITE['cacheFileDir']; }
    if (isset($SITE['imagesDir']))   {$imagesDir = $SITE['imagesDir'];}
    if(isset ($SITE['tz']))          {$ourTZ = $SITE['tz'];}
    if(!function_exists('date_default_timezone_set'))
    {
        putenv("TZ=" . $ourTZ);
    }
    else
    {
        date_default_timezone_set("$ourTZ");
    }
    
    // get path info & protect for cross-site scripting vulnerability
    $sri = ($_SERVER['REQUEST_URI']) ? str_replace('#SA', '', htmlspecialchars(strip_tags($_SERVER['REQUEST_URI']))) : '';
    
    // set borders
       $bbrdr = 'border-bottom:thin solid black';       // bottom
       $lbrdr = 'border-left:thin solid black';         // left
       $rbrdr = 'border-right:thin solid black';        // right
       $tbrdr = 'border-top:thin solid black';          // top
       $sbrdr = 'border-right:thin solid black; '.
                'border-left:thin solid black';         // side
    
    //Define table to display after each storm report
    $afterTable = "<table style='margin-bottom: 5px;' border='0' cellpadding='0' cellspacing='0' width='100%'><tbody><tr><td><img alt='' src='images/1pixel.gif' border='0' height='7' width='7'></td><td class='shadow-mid' width='100%'><img alt='' src='images/1pixel.gif' border='0' height='7' width='7'></td><td><img alt='' src='images/1pixel.gif' border='0' height='7' width='7'></td></tr><tbody></table>\n";
    
    // Let's assign the table some styles
       $noMessageStyle                              = "width:{$width}; text-align:center; margin:0px auto; background-color:{$bkgColor};";
       $td1Style                                    = "{$tbrdr};{$sbrdr}; padding:2px 0px 2px 6px;  background-image:url({$imagesDir}headerbgd2.gif); color:{$dtColor};";
       $td2Style                                    = "{$sbrdr}; padding:6px 0px 0px 6px;";
       $td3Style                                    = "{$sbrdr}; line-height:5px;";
       $td4Style                                    = "{$sbrdr}; {$bbrdr}; padding: 2px 6px 6px 6px;";
    
    
    //Set message to display if there were not report
        $noStormMessage                                     .= "<table style='{$noMessageStyle}' cellpadding='0' cellspacing='0'>\n";
        $noStormMessage                                     .= "<tbody>\n";
        $noStormMessage                                     .= "  <tr><td style='{$td1Style}'>LIVE STORM SPOTTER REPORTS</td></tr>\n";
        $noStormMessage                                     .= "  <tr><td style='{$td4Style}'>There are currently no storm reports</td></tr>\n";
        $noStormMessage                                     .= "</tbody>\n";
        $noStormMessage                                     .= "</table>\n";
        $noStormMessage                                     .= $afterTable;
    
    $xml = simplexml_load_file($data);
    
    //Set initial output to false
    $tData = false;
    foreach($xml->report as $report)
    {
        $date        = $report['stamp'];
        $time        = strtotime($date.'UTC');
        $dateInLocal = date("D g:i a", $time);
        $narrative   = $report['narrative'];
        $loc         = $report['city1'];
        $tz          = $report['tz'];
    
        $stormType = 'Unknown';
        foreach($report->attributes() as $typeKey => $id)
        {
            if($id == 1)
            {
                if(array_key_exists($typeKey, $stormTypesAry))
                {
                    $stormType = $stormTypesAry[$typeKey];
                }
                break;
            }
        }
    
        $stormTypesAry = array(
        'tornado' => 'Tornado',
        'funnelcloud' => 'Funnel Cloud',
        'wallcloud' => 'Wall Cloud',
        'rotation' => 'Rotation',
        'hail' => 'Hail',
        'wind' => 'Wind',
        'flood' => 'Flood',
        'flashflood' => 'Flash Flood'
    );
    
    $reportColor = '';
    
               switch($stormTypesAry)
    {
                  case 'Tornado':
                        $reportColor = 'rgba(128, 128, 128, 0.4)';
                                  break;
                  case 'Funnel Cloud':
                        $reportColor = 'rgba(255, 222, 173, 0.4)';
                                  break;
                  case 'Wall Cloud':
                        $reportColor = 'rgba(255, 20, 147, 0.4)';
                                  break;
                  case 'Rotation':
                        $reportColor = 'rgba(255, 228, 181, 0.4)';
                                  break;
                  case 'Hail':
                        $reportColor = 'rgba(255, 255, 0, 0.4)';
                                  break;
                  case 'Wind':
                        $reportColor = 'rgba(255, 0, 0, 0.4)';
                                  break;
                  case 'Flash Flood':
                        $reportColor = 'rgba(255, 165, 0, 0.4)';
    
    
    }
    
    // Set table style
       $tableStyle = "width: 100%; margin:0px auto; background-color:{$bkgColor};";
       $td1Style = "{$tbrdr};{$sbrdr}; padding:2px 0px 2px 6px;  background-image:url({$imagesDir}headerbgd2.gif); color:{$dtColor};";
       $td2Style = "{$sbrdr}; padding:6px 0px 0px 6px; background-color:{$reportColor};";
       $td3Style = "{$sbrdr}; line-height:5px; background-color:{$reportColor};";
       $td4Style = "{$sbrdr}; {$bbrdr}; padding: 2px 6px 6px 6px; background-color:{$reportColor};";
    
    
     // construct data for table display
        $tData .= "<table style='{$tableStyle}' cellpadding='0' cellspacing='0'>\n";
        $tData .= "<tbody>\n";
        $tData .= "  <tr><td style='{$td1Style}'><b>{$stormType}</b></td></tr>\n";
        $tData .= "  <tr>\n";
        $tData .= "    <td style='{$td2Style}'>Reported: <b>{$dateInLocal}</b>   -   </b>Location: <b>{$loc}</b></td>\n";
        $tData .= "  </tr>\n";
        $tData .= "  <tr><td style='{$td3Style}'> </td></tr>\n";
        $tData .= "  <tr><td style='{$td4Style}'>Description: <b>{$narrative}</b></td></tr>\n";
        $tData .= "</tbody>\n";
        $tData .= "</table>\n";
        $tData .=  $afterTable;
    
     }
    
    //If no storms were in the source, set no storm message
    if(!$tData)
    {
        $tData = $noStormMessage;
    }
    
    echo $tData;
    
    ?>
    

    It should take this code to assign the colors....

    $stormTypesAry = array(
        'tornado' => 'Tornado',
        'funnelcloud' => 'Funnel Cloud',
        'wallcloud' => 'Wall Cloud',
        'rotation' => 'Rotation',
        'hail' => 'Hail',
        'wind' => 'Wind',
        'flood' => 'Flood',
        'flashflood' => 'Flash Flood'
    );
    
    $reportColor = '';
    
               switch($stormTypesAry)
    {
                  case 'Tornado':
                        $reportColor = 'rgba(128, 128, 128, 0.4)';
                                  break;
                  case 'Funnel Cloud':
                        $reportColor = 'rgba(255, 222, 173, 0.4)';
                                  break;
                  case 'Wall Cloud':
                        $reportColor = 'rgba(255, 20, 147, 0.4)';
                                  break;
                  case 'Rotation':
                        $reportColor = 'rgba(255, 228, 181, 0.4)';
                                  break;
                  case 'Hail':
                        $reportColor = 'rgba(255, 255, 0, 0.4)';
                                  break;
                  case 'Wind':
                        $reportColor = 'rgba(255, 0, 0, 0.4)';
                                  break;
                  case 'Flash Flood':
                        $reportColor = 'rgba(255, 165, 0, 0.4)';
    
    
    }
    
    

    Then assign the table color style like so...

    $td4Style = "{$sbrdr}; {$bbrdr}; padding: 2px 6px 6px 6px; background-color:{$reportColor};";
    

    What am I missing or overlooking?

     

    -Thanks

     

     

    I may stand corrected here but at least one issue is that you are trying to pass an entire array to your switch statement, which as far as I am aware isn't possible. A switch usually takes a single value to evaluate against. 

     

    So you might want to do a foreach statement and run the switch in a function that can be called on each iteration.

  10. Hi Guys

     

    I have been a jquery junky for a bit too long and neglected much of the raw javascript behind it...hence this simple question.

     

    When I try to register an event in the format of :

    element.onclick = funcName;
    

    the only way I can get this to work is with:

    document.getElementById('elementId').onclick = myFunc;
    

    Whereas if I try and give this event a handle (below) it doesn't work at all and I get an 'undefined' error in console even though it plainly is defined. But surely these two statements amount to exactly the same thing? 

    var someElement = document.getElementById('elementId');
    
    someElement.onclick = myFunc;   // This doesn't work
    

    So what am i missing?

     

    Thanks,

     

    Drongo

  11. Hello

     

    I have a quick question. I want to make a custom 500 error page. I understand this is achieved by tweaking httpd.conf file to direct to a specific file in the event of a 500 error.

     

    What I want to know is if I make a html 500 error page should this be located on another server? The logic being that if the server can't render any of the normal pages on a site due to a 500 error why would it be able to render my customer 500 page. Does that make sense? And whats the best practice here?

     

    Thanks,

     

    Drongo

  12. Worked it out now.

     

    Seems you have to declare that the first array level is an array too:

     

    var locObj = [];
    locObj[1] = [];
    locObj[1]['top'] = 'twinky'
    
    alert(locObj[1]['top']);
    

     

     

    Just thought I would post back in case anyone else gets stuck on something similar.

     

    Though why you can't just write it like php is hard to fathom - still that's javascript for ya!

  13. Hi Guys

     

    Super simple question. I want to create a multidimensional JS array where I can define the keys. Perhaps my mistake is using similar syntax to php but the following code throws an error in chrome console saying "Uncaught TypeError: Cannot set property 'top' of undefined "

     

    Can anyone nudge me in the right direction on this?

     

    var locObj = [];
    locObj[1]['top'] = 200;
    alert(locObj[1]['top']);
    

     

     

  14. I am not entirely sure what this is called, but say for example you have some text on a site, and you want to edit it right there and then, and you just click on the text, and it changes to a text field and you edit the text, then onblur it updates the text with the new content form the text field.

     

    What is this called, and what is the best and easiest method of doing it?

     

    Best way to do it... There are lots of methods for achieving this but all depends on how complex you want to make it. If you need the fields to be draggable or sortable then you may opt for a different option but what follows is a simple example to highlight how easy it is.

     

    Just as a quick illustration (and i am typing this directly in so sry if it doesn't work)

     

    <form>
    
    Country: 
    <input type="text" name="someField"  value="WHATEVER"  
    onblur="this.style.border='0px'; setAttribute('readonly','true')" 
    onfocus="this.style.border='1px solid black'; removeAttribute('readonly','0')">
    </form>
    
  15.  

    Hi, New to php here please help me out.

    So I have been trying to use the mail function to send mail to me, but it's not working I know i changed the fakeemail@example.com to mine, but it's not working and I can't figure out why. Plus do you know how I can add the emailers name and his email sent additionally with the message to me. Thanks.

    <?php  
    
    if ($_SERVER['REQUEST_METHOD'] == 'POST' ) {
    	if (mail('fakeemail@example.com','New Website Message', $_POST['message'])) {
    		$status = "Thank you for your message {$_POST['email']}";
    	} 
    }
    
    ?>
    <html>
    <head>
    	<title></title>
    	<style>
    		label {display: block;}
    		form ul {margin: 0; padding: 0;}
    		form li {list-style: none; margin-bottom: 20px;}
    	</style>
    </head>
    <body>
    	<h1>Contact Form</h1>
    	<form action="" method="post">
    		<ul>
    			<li>
    				<label for="name">Name: </label>
    				<input type="text" name="name" id="name">
    			</li>
    
    			<li>
    				<label for="email">Email: </label>
    				<input type="text" name="email" id="email">
    			</li>
    	
    			<li>
    				<label for="message">Your Message: </label><br />
    				<textarea name="message" id="message" cols="30" rows="10"></textarea>
    			</li>
    
    			<li>
    				<input type="submit" value="Go!">
    			</li>
    		</ul>
    	</form>
    	<?php  if (isset($status)) echo $status; ?>
    </body>
    </html>
    

     

    Your logic should look something like this:

     

    if(isset($_POST['email'])) 
    {
    
    $to  = 'YourEmail@host.com';
    
    $subject = 'Your Subject Line goes here';
    $message = $_POST['message'];
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    
    // Mail it
    mail($to, $subject, $message, $headers);
    
    
    
    }
    

     

     

    You can add in additional headers etc. which is all explained here - http://php.net/manual/en/function.mail.php

     

    But that should get you started. You probably want a better way of checking if the form has been submitted - i just used $_POST email for an example.

  16.  

    Hi, I'm trying to make a php register and login form but it seems almost impossible. I've got this far and it keeps returning a row error and I have no idea what that means or what would be causing it? It keeps returning the "elseif(!mysql_num_rows($r))" and I have no idea why it's doing that? Really need help on this one cause I've been stuck on this problem for around 1 month now and no one seems to know why it's doing this. Thanks.

     

     

    LOGIN.PHP

     

     

    <?php 
    session_start();
    include "dbConfig.php";
    
    $errorMsg = "";
    
    if ($_GET["op"] == "fail") 
    { 
    $errorMsg = "* You need to be logged in to access the members area!";
    }
    
    if ($_SERVER['REQUEST_METHOD'] == "POST") 
    { 
       $username = trim($_POST["username"]);
       $password = trim($_POST["password"]);
       
       if (empty($username) || empty($password))
    {
    $errorMsg = "* You need to provide a username & password.";
    }
       else
    {
    $usernameSQL = mysql_real_escape_string($username);
    $passwordSQL = crypt($password);
    
    $q = "SELECT * FROM Table1
     WHERE username='$usernameSQL' 
       AND password='$passwordSQL' 
     LIMIT 1"; 
       $r = mysql_query($q) or die("Error: " . mysql_error() . "<br>Query: " . $q);
    if(!$r)
            {
                $errorMsg = "* Wrong username or password.";
            }
            elseif(!mysql_num_rows($r))
            {
                $errorMsg = "* Sorry, couldn't log you in. Wrong login information.";
            }
            else
            {
                $_SESSION["valid_id"] = $obj->id;
                $_SESSION["valid_user"] = $username;
                $_SESSION["valid_time"] = time();
                header("Location: members.php");
    exit();
            }
    }
    }
    ?>
    

     

     

     

     

     

     

     

     

     

     

    REGISTER.PHP

     

     

    <?php 
    include ("dbConfig.php"); 
    
    if ($_SERVER['REQUEST_METHOD'] == "POST") 
    {
    
    
    	$usernameSQL = mysql_real_escape_string($_POST['username']);
    	$emailSQL = mysql_real_escape_string($_POST['email']);
    	$passwordSQL = mysql_real_escape_string($_POST['password']);
    	$passwordSQL = crypt($password);
    	
    	$q = "INSERT INTO Table1(username, email, password)VALUES('$usernameSQL', '$emailSQL', '$passwordSQL')";
    	$r = mysql_query($q);
    	header("Location: register.php?op=thanks");
    	exit();
    
    }	
    	
    	
    ?>
    

     

    Wouldn't advise using mysql anymore - it's deprecated. Use MySQLI or PDO.

     

    Have you tried some debugging. I would suggest some of the following:

     

    • echo out the crypted password and username after you set them and manually compare them to what you have in your database

       

    • try tweak your query so you are only selecting the username, then only selecting the password - this might give you some idea of what variable is failing to match
  17. Hi Guys

     

    I need to setup a MySQL user account so I can connect (using PHP) both on the server where MySQL resides and remotely from another server (these are load balanced servers).

     

    I read a MySQL article here: http://dev.mysql.com/doc/refman/5.1/en/adding-users.html - this seems to suggest in order to do this I would need to setup two user accounts as follows:

     

    CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
    GRANT ALL PRIVILEGES ON MyDB.sometable TO 'monty'@'localhost'
       
    CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
    

     

     

    I am not overly familiar with creating users so apologies for the noob questions about to follow:

     

    1. Is it correct that I need to setup two users with the same username only one as localhost and one with wildcard to be able to use the database locally and remotely ?
       
    2. Rather than use a wildcard would it be more secure to use the remote server's IP - i.e. 'monty'@'SomeIPaddress'?
       
    3. Do I need to grant privileges on the second user - i.e. 'monty'@'%' . Or does this account inherit the same privileges from 'monty'@'localhost'?

     

    I would obviously not grant all privileges either but the above is just for simplicity.

     

     

    Is that all I need to do?

     

    Thanks

     

    Drongo

  18. Hi guys

     

    I implemented the code above as per the solution given but I seem to have a strange issue.

     

    when I set outlook 2007 to receive plain text email only and perform a test send outlook seems to ignore the plain text version in the email and simply defaults to a plain text version it seems to derive from the html version.

     

    has anyone seen this happen before and is to the code or something to do with outlook?

  19. Drongo,

     

    Not a problem, glad I could help.

     

    As for attachments I don't think multipart/related is what you're looking for.   multipart/related as I understand it are for emails which include different sections to complete an email... Like inline images and things like that.  Or at least that how I understood  https://tools.ietf.org/html/rfc2387.  I believe for things like attachments you'll want to use multipart/mixed.

     

    Another thing you may want to consider is to use some prebuilt libraries.  Might save you alot of greif as most of this kind of stuff has already been written and available for your use.  I know things like Zend Framework have some built in email libraries that you can use, or another one that I've seen recomended quite a bit is PHPMailer.  Might save you some headaches.

     

    Westin

     

     

    Ahh I see. I need to go do some reading me thinks!   Heard of phpmailer but not used it - probably should check these out but I am the worst person for wanting to do it all myself to learn how it works ha!  There's a control freak in all of us I guess :)

     

    Anyway thank you very, very much for the help!

  20.  

    OK Folks:

     

    I am totally starting fresh with learning PHP starting with my first program that simply says "Hello World"

     

    So, I've been watching a really cool video on YouTube that has been showing me how to write PHP code and as with any programming language, the first thing you learn is how to print the words "Hellow World" in the browser.

     

    Anyway, so I have the following program, written in NotePad++:

     

     

    <?PHP
     
    print "Hello World";
     
     
     
    ?>
     
    But, when I tell NotePad++ to launch the code in Chrome, instead of showing me just the words Hello World, it displays the entire code I wrote on the page as:
    <?PHP
     
    print "Hello World";
     
     
     
    ?>
     
    This is NOT the desired result.
     
    Also, in NotePad++, I want to upload this file to my web site, I see where there is an upload button, but it is not enabled to allow me to upload this test program to my site.
     
    I'm stuck!!!  Any suggestions ?
     
    Thanks,
     
    Steven Schuyler
    Berkeley, CA

     

    You should probably download an ftp program such as filezilla to push files to your server - never used notepad++ for it but I wouldnt trust the results tbh.

     

    Also, to my knowledge, you cannot execute php code without a server.  If you want to run php code locally you'll need to download something like WAMP server (http://www.wampserver.com/en/) which you can install and run as a server on your computer. This will then let you execute your php scripts. WAMP is insanely easy to install.

     

    Hope that helps!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.