SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist Caesar's Avatar
    Join Date
    May 2000
    Location
    On some harddisk
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to edit before inserting record

    Hi guys,

    Let's say that I have the following code:

    Code:
    <?php
    if(!$submit)
    {
    ?>
    <form action=abc.php method=post>
    <table border=1>
    <tr><td>Please enter your url: </td>
    <td>http:// <input type=text size=10 name=url></td></tr>
    <tr><td colspan=2><input type=submit name=submit value=submit></td></tr>
    </table></form>
    <?
    }else{
    //db connections
    
    $url+="http://";
    echo $url;
    
    // i'm trying to make the user type only the part of the address (such as msn.com)
    
    // in the else area, I want to append a "http://" in front of the $url which he submitted earlier
    The problem is that the above wouldn't work. Obviously I'm doing something wrong. Can anyone guide me?

  2. #2
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    //$url+="http://"; 
    // becomes:
    $url "http://".$url;

    ?>
    I think that's what you're looking for.

    S

  3. #3
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    + doesn't work with strings, instead of using += use .=
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  4. #4
    SitePoint Evangelist Caesar's Avatar
    Join Date
    May 2000
    Location
    On some harddisk
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good one Karl! Thanks!
    Go increase web site traffic by using 27 proven strategies!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •