Christian F.
Staff Alumni-
Posts
3,072 -
Joined
-
Last visited
-
Days Won
18
Christian F. last won the day on June 23 2013
Christian F. had the most liked content!
About Christian F.
Profile Information
-
Gender
Male
-
Location
Norway
Recent Profile Visitors
49,701 profile views
Christian F.'s Achievements
Member (2/5)
232
Reputation
-
To quote the thread you linked to, Csharp:
-
Creating a sign up form for a conference
Christian F. replied to webdevdea's topic in PHP Coding Help
I think you need to go back to the basics, as you clearly don't understand how PHP works. Just throwing code together, in the hopes that it'll work, isn't programming. Worse, it will create an enormous amount of trouble for you, trouble which you will not be able to figure out on your own. Anything you're unsure about in my first post you'll have to search for information on, and read up on every single detail of it. Otherwise you're just flailing about, drowning without even an attempt at swimming. -
Creating a sign up form for a conference
Christian F. replied to webdevdea's topic in PHP Coding Help
You've done half of two of the things I listed... It's a start, but not much more than that. You still have a lot of reading up to do. -
To give a better explanation of what URL rewriting is about: Now, the trick is that the request comes from the client. Which means that the URLs you use in the HTML code needs to be of the "nice" variant. Otherwise the client won't know about them, and just use the plain old ones. So, if the valid/proper URL would be this one: www.example.com/index.php?example=value&another=value2And you want to look it nice, like this: www.example.com/value/value2Then you need to make a rule to rewrite it from the invalid version, to the proper target URI. RewriteRule ^([\w]+)/([\w]+)$ index.php?example=$1&another=$2Where $1 and $2 are what's captured by the character groups inside of the parentheses. This will tell the server that when the client is asking for "/something/other", it is really asking for "index.php?example=something&another=other". There are some other details to this, such as flags to ensure that it only matches when there are no existing files. All of which can be read about in the Apache docs.
-
CANT UNDERSTAND WHY THIS ISN'T WORKING
Christian F. replied to Orionsbelter's topic in PHP Coding Help
Please clean up your code, with proper indentation, so it's actually readable. I suspect that you might be able to spot the error yourself, after doing this. Secondly, please use proper grammar. I'm thinking especially of punctuation. Make your question easy to read, and more people will read it. Make it unnecessary hard to read, by skipping out on grammar, and people won't bother with reading it. Lastly, no need to shout (all caps). In fact, doing so is considered quite rude, and will only serve to give your thread less attention. PS: I recommend that you read this article. Should help you get the help you're looking for. -
how to edit,delete records from 1 common place ?
Christian F. replied to RroniDT's topic in PHP Coding Help
We don't write the code for you, that's your job. We're here to give advice and help people learn, not work for free. I've given you what you need to be able to figure this one out on your own, all you need to do is to read, think, and try. Should you happen to get stuck on something, please feel free to post what you've done, explain what you're stuck on, and why. Then I'm sure someone will be along to help you get over that hurdle, or offer a tip on how to improve it so that you can avoid said problem. Good luck! -
Creating a sign up form for a conference
Christian F. replied to webdevdea's topic in PHP Coding Help
Seeing as this is a school project, I won't tell you how to fix this completely. I will, however, give you hints as what you should look at. Seeing as one tends to learn best by figuring out the problem, and its solution, oneself. First order of business would probably be to fix your indentation and use of white space, both in the HTML code and the PHP code. Having it properly indented and using a consistent style makes it a lot easier to spot problems, as they tend to break the established pattern. Not to mention it'll help you keep track of what happens when, as you'll have a visual clue to help you group the logic of the code. Second order of business would be to remove all uses of the global keyword. I won't go into all of the reasons, but trust me when I say that it's one of the primary causes for some of the hardest bugs to track. I recommend reading up on how to pass function parameters and returning values, as that is how you should be doing it. Then you'll want to do some proper input validation on the data you're getting from the form. Right now you're attempting to use the data, before you've even verified their existence. (Assigning to a variable is using.) At the very least you should be checking if a form has actually been submitted, before you run through the code to process said form. isset and the filter_var functions are two cornerstones in how to perform input validation. Just remember to validate input as the first thing you do, even before assigning it to another variable from the $_POST or $_GET arrays. After you've fixed the indentation, you should already have noticed one of the reasons you're getting an error message. (If you don't see an error message, read the links in Jessica's signature.) That should also make you aware of another problem you have, one of logic. Now this is the hardest part. Spotting logic errors means that you don't only have to understand what the code actually does (as opposed to as what you wanted it to do), but you also have to understand the problem and the correct solution to it. Only after you've understood the problem fully, and solved it, will you be able to write the correct code to replicate/automate said solution. That said, you really want to take a look at the first IF-test of your calculateCost () function. Bonus hint: If you move all of the processing PHP code to above the first line of HTML, your script is not bound to what you've already sent to the client. Enabling you to use the really nifty header function. Something which will help make your script a lot more flexible, and easier to write. -
No, I'm afraid there are no simple guides. The reason as to why there isn't one is simple though: There is no one plain and simple answer that is applicable for all situations, it all depends upon the requirements of the application and the client. There are a number of things that one absolutely must do as a minimum, again depending upon what kind of data you're gathering, how you process it, and how you store it. Then there are a number of things that one should do, which is also dependent upon the entire process. Lastly there are a number of things that you might want to consider, if you think they might bring added value or if you have some special requirements. My point is that an e-mail address needs to be treated differently than a user ID, which needs to be treated differently than a password. Also, an application for a personal blog has vastly different requirements than an application meant to be used by a bank. Depending upon what, exactly, "your" application does it is probably somewhere on the "banking" half of that scale. Exactly where I cannot tell without knowing exactly what your requirements are.
-
I don't see any uploading going on there, nor do I fully understand what you're looking to do. Mixing up your terminology a bit, perchance? Just in case you're wondering: Reading a file with PHP (from a client computer) without uploading it is impossible. That's like eating a bag of chips, without opening the bag. Since PHP runs on the server-side it cannot access the file, unless it is uploaded to the server by the client. Same way that you can put the chips in your mouth, without first opening the bag to get to them.
-
You've been given plenty of suggestions, advice and recommendations over the months you've been hacking at this. None of which you seem to have taken to heart. If you're willing to listen now, just go over your old threads, should provide you with ample advice for improvement. Personally, I find the idea of you running any kind of web-based business that you've coded "yourself" terrifying. You simply do not have nearly enough experience nor knowledge with programming to make anything remotely secure enough.
-
You're welcome, glad I could help.
-
You just asked for every row with an e-mail and a pool ID, whether or not they had any results. If you only want those with a result, then you'll need to change the second JOIN into an INNER JOIN. If you have any other criteria, then you'll either have to add them to the relevant ON clause, or add a WHERE clause to the query.
-
Sending only one email rather than multiple from my script
Christian F. replied to Dicko_md's topic in PHP Coding Help
Figuring out how to write the code is your job. We're here to offer you help and advice to overcome problems, and figure out alternative/better solutions, not to do the work for you. Try for yourself, and read up if you don't know how. I've given you all of the tools you need to figure this one out on your own, and with a bit of reading + searching on the net this should be quite easy. If you get stuck, post your code and explain where and why. Then we'll be able to help you some more. -
You don't actually have a JOIN there, just a single select from a single table. Which is why MySQL is complaining about the missing fields. Since you haven't actually JOINed the other table(s), MySQL doesn't know where to look to find the data you're asking for. Luckily, that's an easy fix. In this case, since all of the admins also have (at least) one corresponding record in the pool table, we'll be using INNER JOIN for that. While the results table, which can be empty, is a prime candidate for LEFT JOIN. Meaning the "right hand" (JOINed) table can have 0 rows returned, at it'll still list the results from the "left hand" table. The pattern of a JOIN is to first specify the type of JOIN you want to use, then the name of the table. Next you can give it an alias, which is recommended to cut down on the length. Then you'll need to tell MySQL which conditions to use to determine what rows to JOIN, which is done by using ON and an expression like with WHERE. Basically, something like this: SELECT a.`email`, p.`poolid` FROM `administrators` AS a INNER JOIN `pools` AS p ON p.`adminid` = a.`adminid`You can add more JOINs after one another, to fetch the data from all the necessary tables. Once you've done that, you can add a WHERE clause to give a constraint on the entire result set.Mind you, that you can add more constraints on the JOIN itself, if you have multiple possible results from a JOINed table, but only want some of them. Like if you have a table containing translations, and you only want from a specific language. Then it'd look something like this: SELECT c.`name`, t.`description` FROM `cards` AS c INNER JOIN `card_text` AS t ON t.`card_id` = c.`id` AND t.`lang` = 'en' WHERE c.`id` = 1;
-
Seems like you need to study a bit on how functions work, and variable scope. I would also recommend fixing the indentation in your code properly, as it'll make it a lot easier to see the flow of the execution. In short: Variables defined inside a function does not exist outside of it.
- 13 replies
-
- validation
- form
-
(and 2 more)
Tagged with: