Jump to content

psquillace

Members
  • Posts

    94
  • Joined

  • Last visited

    Never

Posts posted by psquillace

  1. Here is the example from the text

     

    <?
    	$url_page = 'php/created/page/url.php' ;
    	$param1 = 'This is a string';
    	$param2 = '"bad"/<>character$';
    	$linktext = "<Click> & You'll See";
    
    ?>
    <?php
    	// this gives you a clean link to use
    
    	$url = "http://localhost";
    	$url .= rawurlencode($url_page);
    	$url .= "&param1=" . urlencode($param1);
    	$url .= "&param2=" . urlencode($param2);
    
    	// htmlspecialchars escapes any html that 
    	// might do bad things to your html page
    ?>
    <a href="<?php echo htmlspecialchars($url); ?>">
    	<?php echo htmlspecialchars($linktext); ?>

     

     

    and I was following it all and what he was saying until the .= came into the picture, that is where I got lost. I am assuming it means to just append it to the end of the url?

  2. Hello All Again....

     

    Ok, working on the same subject of php of encoding html and the author uses this one out of the blue....

     

     

    $variable .= htmlspecialchars()

     

    Now, there is nothing in there on this, or what this means. When do I use it?

     

    I tried looking on php.net but for some reason, I never understand that site or what they say on a subject. I am sure I will get that site when I use php more..

     

    thanks for any help on this and what this function is or does

     

    Paul

  3. Hello All:

     

    I have a newb question here. In learning php I seem to notice that we use the Curly Braces for the IF/ELSE statements but I have seen them used to seperate variables in like

     

       echo "<b>" . $id . ": {$name} </b>";

     

    now $name is a variable and I think I understand why it my be like that but in leaning from a book, I am a bit confused as to why the author decided to throw that line together that way?

     

    Any thoughts or advice would be appreciated.

     

    Paul

  4. yes the variable i have set for my check box is 'optedin' but I would still need it to return something because of the people who will be looking at the final product will be looking for a Yes or No.

     

    is there a way to have a 'optedin' = FALSE; $optedin = NO or something?

     

    thanks for you help

     

    Paul

     

     

     

  5. Hello All:

     

    I am using a form that when people fill out on my site goes into my account at Constant Contacts. It works fine however, I am trying to add a checkbox to the end of the form by the submit button that says, Opt In.

     

    This is where the customer can opt in for special catalogs we mail. Anyhooo, I have it saying

     

    <? if (isset($optmessage)) {$_POST["Custom_field_3"]}else{$_POST[]} ?>

     

    but I confused myself I think because i do not have it what to post if NOTset or else.

     

    I hope this all makes sense, I am kind of new to php and am a little lost.

     

    Thanks,

     

    Paul

  6. Man C64/128.... those were the days.

     

    I remember programming a image of Alfred E Newman from Mad magazine. They had this 5 page pull out once in one of their issues where you could make an image of him appear on the screen.

     

     

    Just dot matrix but it did cost me $1.75 and a Friday Night.... ;D

     

     

  7. Roop,

     

    Thanks so much for your advice on this subject. When I first started to learn php via www.lynda.com I was sucking it all in as fast as I could because I wanted to know it all. Then I took a break because that was not working, just listening and watching video tutorials.

     

    My second try around, I took the approach you have laid out above and decided the reason I am not learning is because I am not taking the time to do it or practice it.

     

    As long as I got phpfreaks, I think I will have enough mentors on this subject. :D

     

     

    Thanks again for your advice and help on this matter.

     

    Paul

     

     

     

  8. Thanks Phreek

     

    I think you hit the nail on the head with me when you said

     

    One day you will truly wake up and realize that, since you are probably answering more questions than asking, you are now a 'programmer'.

     

    I was always under the contention that I must not be getting this BECAUSE I have all these questions. Thanks again for your very timely answer to my doubts.

     

    Paul

  9. Ok, so basically this is what I got but it is not working.....

     

    <?php
    
    if (isset($_POST['submit'])) {
      $config['url']       = $_POST['url'];
      $config['start_tag'] = "<title>";
      $config['end_tag']   = "</head>";
      $config['show_tags'] = 1;
      $grab = new grabber;
      $grab->grabhtml( $config['url'], $config['start_tag'], $config['end_tag'] );
    
      echo $grab->error;
    
      foreach( $grab->html[0] as $html )
      {
    echo htmlspecialchars( $grab->strip( $html, $config['show_tags'], $config['start_tag'], $config['end_tag'] ) ) . "<br>";
      }
    }
    
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    	<title>Meta Tag Grabber</title>
    </head>
    <body>
    	<form action="http://www.kardwelldev.com/meta-tag-grabber2.php" method="GET">
    	<input type="text" name="url">
    	<input type="submit" name="submit">
    </form>
    </body>
    </html>

     

    sorry to be such a newb on this,

     

    PM

  10. Thanks Thorp for that help,

     

    One last thing though, I tried to make the echo part a bit prettier when it was echoed to the page but when I use \n anywhere in the echo part, it breaks the code.

     

    I also tried to use HTML inbetween the single quotes but that does not do it either.

     

    HOw can I get it to break where I want or make a table for it. Should I make a table then use includes?

     

     

    thanks again for your help,

     

    PM

  11. Hello All:

     

    I need some help with a script I have. I have this php script pasted below which grabs certain tags from a document and pastes it so you can print it out.

     

    What I need to do is have a form that people can fill in the address of the website they want to grab and have it return those results.

     

    I am not sure where to begin though being I am new to php.

     

    thanks for any help or advice,

     

    here is the script

     

    <?php
    
    $config['url']       = "http://www.yoursite.com"; // url of html to grab
    $config['start_tag'] = "<title>"; // where you want to start grabbing
    $config['end_tag']   = "</head>"; // where you want to stop grabbing
    $config['show_tags'] = 1; // do you want the tags to be shown when you show the html? 1 = yes, 0 = no
    
    class grabber
    {
    var $error = '';
    var $html  = '';
    
    function grabhtml( $url, $start, $end )
    {
    	$file = file_get_contents( $url );
    
    	if( $file )
    	{
    		if( preg_match_all( "#$start(.*?)$end#s", $file, $match ) )
    		{				
    			$this->html = $match;
    		}
    		else
    		{
    			$this->error = "Tags cannot be found.";
    		}
    	}
    	else
    	{
    		$this->error = "Site cannot be found!";
    	}
    }
    
    function strip( $html, $show, $start, $end )
    {
    	if( !$show )
    	{
    		$html = str_replace( $start, "", $html );
    		$html = str_replace( $end, "", $html );
    
    		return $html;
    	}
    	else
    	{
    		return $html;
    	}
    }
    }
    
    $grab = new grabber;
    $grab->grabhtml( $config['url'], $config['start_tag'], $config['end_tag'] );
    
    echo $grab->error;
    
    foreach( $grab->html[0] as $html )
    {
    echo htmlspecialchars( $grab->strip( $html, $config['show_tags'], $config['start_tag'], $config['end_tag'] ) ) . "<br>";
    }
    
    ?>

  12. Hello All:

     

    Sometimes I get a bit lost when learning php. I mean, I am trying to learn as best as I can and when I learn something I take on a project that I invent in my head to make sure that I learned it. Sometime though I get lost on the subject and it is a bit discouraging.

     

    Is this normal, to get discouraged in learning coding in general as this is my first code I am learning.

     

    well, aside from HTML but, that was not that hard to pick up.

     

    ANy thoughts of wisdom here would be appreciated.

     

    PM

     

     

     

  13. Hello All:

     

    Currently on a site I have a checkbox for people to check to opt-in to ok to send them emails if checked with

     

    // Check for Opt-In.

    if (!isset($_POST['optin']) && ((empty($_POST['email'])) || !valid_string($_POST['email']))) {

    $optin = FALSE;

    $email = FALSE;

    $canspam = TRUE;

    } else {

    if (isset($_POST['optin']) && (!empty($_POST['email']))) {

    if (check_email_address($_POST['email']) && ($_POST['optin'] == 'TRUE')) {

    $optin = $_POST['optin'];

    $email = $_POST['email'];

    $canspam = TRUE;

    } else {

    $message .= 'To receive emails, you need to check the box and provide a valid email address!<br>';

    }

    } else {

    $message .= 'To receive emails, you need to check the box and provide a valid email address!<br>';

    }

    }

     

     

    However, I would like it to say NO when someone does not check the box.

     

    How would I add that in here?

     

     

    thanks for any advice,

     

    Paul

     

     

×
×
  • 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.