PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm trying to create a script that will allow a person to enter only 2 fields into a database. I've gotten quite far with writing the PHP script and it is actually working! but the problem is, whenever I run everything (HTML Form which posts to PHP script which sends info to DB), the auto_increment field in my DB is incremented; however, the 2 fields are empty (except 1 whitespace. Below is the script I'm using. If anyone can help, that would be very great. thanks
I figured it's the php.ini file where I would turn the register_globals to On, so I did, but the same thing still happens. And I restarted the server before I retested the form. Any other ideas would be greatly appreciated. Thanks
Try displaying the insertion query before you run it. You will probably see that the fields are all blank. This is due to the aforementioned register_globals and initialization.
register_globals should not be on.
You should initialize the variables you need from the posted data.. $id isn't passed. $songname should be initialized with $_POST['songname'] .. and so forth. The variables may need additional processing to "fix" potential insertion problems and injection risks.
$sqlquery = "INSERT INTO $table
VALUES('".$id."','".$songname."','".$songurl."')";
instead of just having: $sqlquery = "INSERT INTO $table
VALUES('".$id."','".$songname."','".$songurl."')";
Everything is coming in just smoothly, so hopefully I won't have anymore trouble with this. My next step is to have the download page read those values to make the hyperlink (with the $songname) and to list the songs. I'm pretty sure I'll be ok from here. Thanks everyone.