premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
Not a problem. Alternatively what could be happening is you were getting this notice all the time until a server upgrade or switch happened and notice errors were turned on. They are not a huge problem, but better to remediate them. You can also do a check like so: $_SESSION['username'] = isset($username2[1])?$username2[1]:""; // default it to "" if there is no index in the array Which would not show the notice error, but $_SESSION['username'] would be set to "" (an empty string).
-
The explode of $username did not contain as many fields as you thought it was. $username2 array does not contain an index at 1. I would echo out your username and make sure it is what you were expecting. Also do a print_r on the $username2 array and see what it contains. Just to make sure they are what you expect them to be.
-
PHP would be better as it cannot be disabled. if (!isset($_POST['first_name']) || empty($_POST['first_name'])) { echo 'First name is required.'; exit; } $first_name = isset($_POST[ 'first_name' ])?mysql_real_escape_string($_POST[ 'first_name' ]):null; // repeat this for anything coming in from the form // it will prevent sql injection. $middle_name = $_POST[ 'middle_name' ]; // repeat here $last_name = $_POST[ 'last_name' ]; // and here $phone = $_POST[ 'phone' ]; // and here $email = $_POST[ 'email' ]; // and here The checks can be done a bit nicer with nicer error messages and without exiting the script. That is just a rough example of one way it could be done.
-
$query = "insert into club values (NULL, '$first_name', '$middle_name', '$last_name', '$phone', '$email')"; Then you do not need to but $id in there, as it does not have a value and causes issues as you noticed. Try putting NULL in the id spot. The auto_increment should pick it up and work just fine.
-
Run a check against the DB and use LOWER() in the SQL on the field you do not want duplicated and check it against the field entered. Use strtolower in php to create the same effect so that you know both items are being checked case insensitive. That way it does not matter if they enter it all upper or lower etc, it should still show that the record is in the database. Another item you can try is adding the "UNIQUE" identifier to the table column's attribute when creating the table. It should make the field be required to be unique, but I would still do the above as an extra measure for case sensitivity.
-
Your understanding is correct. if(isset($_GET['update'])) // missing paran here echo '<meta HTTP-EQUIV="REFRESH" content="0; url=InsertMC.php?update="'.$row['MAINT_ID'].'">'; else echo '<meta HTTP-EQUIV="REFRESH" content="0; url=InsertMC.php">'; You had the quotes switched around. You needed it to start with and end with a single quote in the if statement $row maint_id part since that is what your echo starts and ends with. Should work, I may have missed something, but yea.
-
You never set the variable id. Where is it suppose to come from / what is it suppose to contain?
-
Arrays are your friend. function scale($quantity) { $a = $b = $c = 0; // default the values to 0 if ($quantity <= 4500) { $interval = 1000; $a = 25; $b = 75; $c = 150; } if ($quantity <= 2250) $interval = 500; if ($quantity <= 900) $interval = 200; if ($quantity <= 450) $interval = 100; if ($quantity <= 225) $interval = 50; if ($quantity <= 90) $interval = 20; return array($interval, $a, $b, $c); } list($interval, $a, $b, $c) = scale ($some_number); Something like that should work. list
-
[SOLVED] passing null varchar value from php form to mysql
premiso replied to nomis's topic in PHP Coding Help
You need to provide us with more code. Where does the data get checked and entered into the database? As the issue seems to lie within that. You are not doing enough checks before data is entered as it seems no matter what is entered it goes into the database anyways. You need to add a check before the data gets entered to not enter into the DB if there was a null or error on a required field. If I am missing something I am sorry, just an observation I noticed. -
[SOLVED] Problem with displaying Username on 1st restricted page..
premiso replied to tobimichigan's topic in PHP Coding Help
It is amazing how someone pointing out something makes you see more items: $_SESSION['pfno'] = "username"; You set pfno to be "username" instead of this 4 code you wanted it to be. That may be a place to start, also see Bjom's comment about the setting of session username. -
<?php // first up there was no statement here ? if (isset($_POST['first_name'])){ // lets check if a value of the form is there $first_name = isset($_POST[ 'first_name' ])?mysql_real_escape_string($_POST[ 'first_name' ]):null; // repeat this for anything coming in from the form // it will prevent sql injection. $middle_name = $_POST[ 'middle_name' ]; // repeat here $last_name = $_POST[ 'last_name' ]; // and here $phone = $_POST[ 'phone' ]; // and here $email = $_POST[ 'email' ]; // and here if ($_POST['email'] == $_POST['emailconfirm']) { // the email fields checked out $query = "insert into club values ( '$id', '$first_name', '$middle_name', '$last_name', '$phone', '$email')"; $results = mysql_query( $query ) or printf( "Query error: %s", mysql_error() ); }else { // some type of error message generated } } // mysql_close(); // really not necessary unless you are working with persistent connections ?> <form action="<?php $PHP_SELF; ?>" method="POST" onsubmit="return validate_form(this)"> <table width="361" border="0" cellspacing="0" cellpadding="5"> <tr> <td>First Name *</td> <td><input type="text" name="first_name" /></td> </tr> <tr> <td>Middle Name</td> <td><input type="text" name="middle_name" /></td> </tr> <tr> <td>Last/Family/Surname *</td> <td><input type="text" name="last_name" /></td> </tr> <tr> <td>Phone (xxx-xxx-xxxx)</td> <td><input type="text" name="phone" /></td> </tr> <tr> <td>Email Address *</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Confirm Email *</td> <td><input type="text" name="emailconfirm" /></td> </tr> </table> <p><br /> <input type="submit" value="Submit" /> </p> </form> Give that a try and see if it helps. I commented the code where I modified it.
-
[SOLVED] Problem with displaying Username on 1st restricted page..
premiso replied to tobimichigan's topic in PHP Coding Help
I would recommend a better test to see if that session value isset: if (!isset($_SESSION["pfno"])) That way you can be sure it had to be set and not just returning cause the value was false. As far as anything else, I really cannot see where it may be going wrong. Try that and see if it helps the problem. -
Simply put...google...which evidently pulled up a phpfreaks forum post. http://www.phpfreaks.com/forums/index.php?topic=157080
-
[SOLVED] How should i call the $_POST of these textboxes
premiso replied to mike12255's topic in PHP Coding Help
echo $_POST['$i']; Single quotes are taken literally. echo $_POST[$i]; Either do no quotes (above) or double quotes (below) echo $_POST["$i"]; -
It could be, especially if using the persistant, not permanent, connection type. Is there any reason you are using that? That could be causing it, but see my answer above, if you do not know why you are using it, chances are you do not need the pconnect, just use the regular mysql_connect function instead.
-
A question about PHPFreaks home page
premiso replied to dpacmittal's topic in PHPFreaks.com Website Feedback
Well then, I believe dpacmittal. I believe they thought about it, then decided that it was not worth the effort. From my own expierence with working off of 2 seperate systems, it is not worth it. -
A lot of times the out of memory can be caused by infinite loops. I would check any loops that you have. Also if you are reading/using images from the DB or inside the script, try and make that as efficient as possible as it can easily eat up memory. It is hard to really give you more detail of help without seeing any code as it could be how you coded it as well that is inefficient and eating up the memory.
-
I do not think it is possible. As with header or header modifying programs anything can be "forged" or "spoofed". It sounds like you setup measures, but unfortunately, flash is not very secure. I do not know of any other measures you can take. You can setup the "File calling me is" via headers I believe, but since they are headers that can also be spoofed, especially since it is cross-domain. If it was on your own server or the server where the script is set I am sure it could be done and secured.
-
You can store a hashed "challenge" answer in the .swf file. This is not 100% guranteed, as it can probably be viewed in Notepad as raw text. But just pass that challenge question to the php script if it is right, then you accept the code, if not then you do not accept. But as stated it is not fool proof as either viewing the source of the swf and or sniffing the packets would yield what it should be. But it is better than nothing.
-
Look into curl as that should provide you with what you are looking for.
-
There are also a few function available to PHP for you to look at, however I would suggest setting it at the server level to to GMT 0, so it is stored in your database at a neutral time, then use PHP to display different timezones for the users. Not required, but can make it easier incase you change server locations etc. http://us3.php.net/manual-lookup.php?pattern=timezone&lang=en
-
You may never be able to solve the answer. From what I have found out is that most of those services, like Hotmail Yahoo etc filter any email where the domain it is being sent from does not have a mail record. I would check via a free online service to see if your domain IP shows as having a mail server. If it does not, you may want to contact your host for a way to remediate that. But also adding more thorough headers can solve the problem as well. I would take a look at some of the headers found at mail and maybe add more in there to help "prove" it is not spam. Me, I stopped using my server's mail service and instead use GMail hosted with 3-4 accounts that I use to send mail from as GMail allows for 500 emails a day per account on their Hosted side. I rarely send 500, but just incase of a huge mail day I have the backups to go to. Hope that helps.
-
http://dev.mysql.com/doc/refman/5.0/en/select.html Look into "LIMIT" at the page above. For a tutorial on "Pagination" which is what you are looking for, take a look Here
-
Try using all the parameters for setcookie or use session instead. If you choose to use session remember to call session_start. Also using @ on the mysql statements supresses the errors. So if there is an error causing the problem you will never know. One other item, I would change this: $referer = $_SERVER[HTTP_REFERER]; to $referer = isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:false;