1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Php Form To Db

Discussion in 'PHP' started by trenttdogg, Feb 12, 2013.

  1. trenttdogg

    trenttdogg Greenhorn

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    8
    #21
    If I have varchar set to say (20), does it matter if the form allows for more. And this form is going to be in the access panel and probably in a password protected folder. Will that provide more security?
     
    trenttdogg, Feb 14, 2013 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #22
    MySQL will automatically truncate -- beware some other SQL engines will throw an error instead, but on mySQL; no problem it just chops off the extra -- but beware that it will just chop off the extra as that too can cause... issues. That's why you put it on the form as a reminder, but don't rely on it server side and if using mySQL, set the field size to the limit you want, or on other engines manually chop it off.

    If it's in an admin panel under lock and key, I'd go ahead and not bother with stripping out markup since you might want to add markup to it. If it were public, I'd run strip_tags on the $_POST values when plugging them into the arrays, and maybe even a htmlspecialchars on them so as to strip out any code the user might have entered.

    There's a reason things like forums escape markup to show it as plaintext (htmlspeicalchars) and then use various regex to implement bbCode instead.
     
    deathshadow, Feb 14, 2013 IP
  3. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #23
    In response to trentdog
    
    [LIST=1]
    [*]<form action="insert.php" method="post">
    [*]subject: <input type="text" name="subject">
    [*]category: <input type="text" name="category">
    [*]<input type="submit">
    [*][B]</form>[/B]
    [/LIST]
    
    HTML:
     
    ezprint2008, Feb 14, 2013 IP