SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need Help, not sure what I'm doing wrong

    I have a form www.ol3on3streetball.com/streetballtester.html. Below is the html for that page:

    Code:
    <form action="https://www.ol3on3streetball.com/processform.php" method="post">
    <input type="hidden" name="_success" value="http://www.olclothing.com">
    <p>
      <b>Player 1</b></p>
      <p>First Name: 
      <input type="text" name="PlayerFirstName1" size="12" maxlength="30">&nbsp;&nbsp;&nbsp; 
      Last Name: <input type="text" name="PlayerLastName1" size="12" maxlength="30">&nbsp;&nbsp;&nbsp;  </p>
      <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
    </form>
    As you can see this is suppose to go to a php page. Here is my php code:

    PHP Code:
    <?php 
    $connection 
    mysql_connect("io2.your-site.com","myusername","password" ); 
    $db mysql_select_db("overlook"$connection); 

    $sql "INSERT INTO Players (PlayerFirstName1, PlayerLastName1) VALUES ('$PlayerFirstName1', '$PlayerLastName1')"
    //all the variables come from the form that was submitted to this script 

    $sql_result mysql_query($sql,$connection) OR die("Couldn't insert the players into the table." ); 

    //Now if you wanted, you could send them to that payment page 
    header("Location: http://www.olclothing.com" ); 
    ?>
    I also have a table set up in my database named "Players" already.

    When I go to www.ol3on3streetball.com/streetballtester.html and hit submit I get the message "page cannot be displayed"

    If I typed in www.ol3on3streetball.com/processform.php directly I get
    "Couldn't insert the players into the table."

    I would appreciate if anyone could tell me where I'm going wrong.

  2. #2
    SitePoint Addict been's Avatar
    Join Date
    May 2002
    Location
    Gent, Belgium
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's probably something wrong with the ssl setup on that site, you can go to http://www.ol3on3streetball.com/processform.php but not to https://www.ol3on3streetball.com/processform.php as put in the action attribute of the form tag
    Per
    Everything
    works on a PowerPoint slide

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by been
    There's probably something wrong with the ssl setup on that site, you can go to http://www.ol3on3streetball.com/processform.php but not to https://www.ol3on3streetball.com/processform.php as put in the action attribute of the form tag
    Ok I fixed that and that is why it wouldn't display my php page. However I am still getting "Couldn't insert the players into the table"

    I don't see any errors in my php script but I would appreciate if someone could double check it for me.

    Thanks

  4. #4
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try :

    PHP Code:
    $sql_result mysql_query($sql,$connection) OR die("Couldn't insert the players into the table, here's why:" mysql_error()); 
    My name is Steve, and I'm a super-villian.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lieut_data
    Try :

    PHP Code:
    $sql_result mysql_query($sql,$connection) OR die("Couldn't insert the players into the table, here's why:" mysql_error()); 
    It just gave me the same message "Couldn't insert the players into the table"

  6. #6
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the mysql call failed, then mysql_error should have details on the problem, but if for some reason it returned an empty string, you should have gotten

    "Couldn't insert the players into the table, here's why:"

    As the return value -- I don't think the code update took place, try again
    My name is Steve, and I'm a super-villian.

  7. #7
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess it didn't update so I uploaded again and got this message:

    Couldn't insert the players into the table, here's why:Unknown column 'PlayerLastName1' in 'field list'

    I doubled check my table and found that I put PlayerLastName instead of PlayerLastName1. I fixed that but now it is giving me

    Warning: Cannot add header information - headers already sent by (output started at /export/home/overlook/www/processform.php:6) in /export/home/overlook/www/processform.php on line 16

  8. #8
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    by the way this is what my php page now looks like

    PHP Code:
    <?php 
    $connection 
    mysql_connect("io2.your-site.com","username","password" ); 
    $db mysql_select_db("overlook"$connection); 

    $sql "INSERT INTO Players (PlayerFirstName1, PlayerLastName1) VALUES ('$PlayerFirstName1', '$PlayerLastName1')"
    //all the variables come from the form that was submitted to this script 

    $sql_result mysql_query($sql,$connection) OR die("Couldn't insert the players into the table, here's why:" mysql_error());   

    //Now if you wanted, you could send them to that payment page 
    header("Location: http://www.olclothing.com" ); 
    ?>

  9. #9
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In order for header to work, it has to output before any other content sent to the browser. Something above this code is outputting to the browser, and as a result you cannot redirect.

    Either find a way to make sure header is outputted first, or call ob_start at the top of your script to buffer output. (Small overhead cost, but maybe worth it)
    My name is Steve, and I'm a super-villian.

  10. #10
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lieut_data
    In order for header to work, it has to output before any other content sent to the browser. Something above this code is outputting to the browser, and as a result you cannot redirect.

    Either find a way to make sure header is outputted first, or call ob_start at the top of your script to buffer output. (Small overhead cost, but maybe worth it)
    I looked at the header link but I'm not really understanding it. Seems like I looking at something that is being taken out of context. Here is my entire code.

    Code:
    <html>
    <head>
    <title>Process Form</title>
    <head>
    <body>
    <?php 
    $connection = mysql_connect("io2.your-site.com","username","password" ); 
    $db = mysql_select_db("overlook", $connection); 
    
    $sql = "INSERT INTO Players (PlayerFirstName1, PlayerLastName1) VALUES ('$PlayerFirstName1', '$PlayerLastName1')"; 
    //all the variables come from the form that was submitted to this script 
    
    $sql_result = mysql_query($sql,$connection) OR die("Couldn't insert the players into the table, here's why:" . mysql_error());   
    
    //Now if you wanted, you could send them to that payment page 
    header("Location: http://www.olclothing.com" ); 
    ?> 
    </body>
    </html>
    I think they are telling me to put (php 3, php 4) at the very top of my page but like I said before it seems that I'm reading something taken out of context.

    Thanks

  11. #11
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <html> 
    <head> 
    <title>Process Form</title> 
    <head> 
    <body> 
    <?php
    header outputs HTTP headers, which according to HTTP Specifiations, must come before any content. Here, you can see that you are ouputting HTTP codes at the top of your page, then calling header later on. This won't work.

    Since all this page does is insert into a database, drop the HTML, and redirect the user to an error page if something bad occurs. Then you can avoid the header problem entirely.
    My name is Steve, and I'm a super-villian.

  12. #12
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lieut_data
    PHP Code:
    <html> 
    <head> 
    <title>Process Form</title> 
    <head> 
    <body> 
    <?php
    header outputs HTTP headers, which according to HTTP Specifiations, must come before any content. Here, you can see that you are ouputting HTTP codes at the top of your page, then calling header later on. This won't work.

    Since all this page does is insert into a database, drop the HTML, and redirect the user to an error page if something bad occurs. Then you can avoid the header problem entirely.
    Hey thanks alot I really appreciate it. Everything works great now. Thanks for your patience. I do just have one more question. The form I will actually use will be on a secure server. Do I need to do anything special to make it work on a secure server?

  13. #13
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great! No problem :-)

    As for the SSL, I shouldn't think so -- it's designed to be transparent. If you *do* run into problems, there's always these forums
    My name is Steve, and I'm a super-villian.

  14. #14
    SitePoint Addict been's Avatar
    Join Date
    May 2002
    Location
    Gent, Belgium
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't forget to change http to https in the action attribute of the form tag

    You could of course use a relative url in the action attribute, so you don't have to worry about forgetting it when you move the site from one server to another.
    Per
    Everything
    works on a PowerPoint slide

  15. #15
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by been
    Don't forget to change http to https in the action attribute of the form tag

    You could of course use a relative url in the action attribute, so you don't have to worry about forgetting it when you move the site from one server to another.
    Thanks for the reminder


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
  •