Leaderboard
Popular Content
Showing content with the highest reputation on 06/14/2024 in all areas
-
Laravel is dumb, but a thing that exists and is popular and is dumb and people do use it. It's primarily an entire framework, as in it provides a dumb foundation for an entire website/application, but there are dumb library aspects to it too. I wouldn't suggest it because it is really more of a dumb framework than a library, so using pieces of it may not work out. Not that I ever have done so myself, given that Laravel is dumb, though I have used Laravel (as a framework) before, so take that with a grain of salt. You should also consider that Laravel is dumb. I would put far more faith in an ecosystem like Symfony, which is pretty much the de-facto choice of libraries for PHP, than I would in random things you'll find across the internet. Especially things that haven't been touched in years, which means they haven't been maintained, and since no code is ever perfect this also means it has bugs that aren't getting fixed. Meanwhile Laravel, despite being dumb, actually uses some Symfony pieces internally, which isn't dumb. Using Symfony does require a little more effort on your part as it tends to try to be powerful and this can mean it sacrifices some ease of use, but this is a good thing as you're working with a - dare I say - not dumb library. But I wouldn't be a senior developer unless I gave you the standard reply: "it depends". The primary matter is going to be what kind of "auth" you're talking about. Do you mean a full user system, like with signups and password resets and an administration tool? Do you mean something to password-protect some files, or a section of your site? Do you need something that looks nice or can it be something super simple provided it can do the job? Do you need to deal with user accounts being added and disabled, or just something quick where you can give out a password to people you want to allow access?1 point
-
Yes, however, people can actually use a DMarc configuration to just flat out reject or quarantine emails that fail SPF or DKIM validation. The other thing to do is to make sure all the domains lineup, so that the user@domain of the email matches the domain check for SPF and DKIM.1 point
-
...Oh wait, you want to validate the sender? I completely misunderstood what you were asking for. Good news: validation of an email's sender is more or less a solved problem with SPF and DKIM records. It's up to the sender to opt-into those things, but if they do, emails passing validation can be pretty confidently attributed to that sender. So check if your emails are being validated like that - which they really ought to be, and I'd be surprised if they weren't. If so then you should be able to retrieve that validation information through PHP.1 point
-
Wow Gizmola. <insert exploding head emoji here> Thanks! You've given me some really good ideas and a lot of information for me to investigate and learn. Greatly appreciated!1 point
-
1 point
-
Oh, SOAP is terrible. Hate it. REST is so much easier to work with. And yeah, XHTML... I miss that. When it was still a thing, and for a while after, that was what I was using for all my stuff. Then they took all the weirdness of HTML 4 and doubled-down on it with 5. Sigh.1 point
-
I have about 10 pounds of old xml books in my office covering all this type of arcana. Fortunately (or not depending on how you look at it) we have people like Requinix and Barand on this forum, who have the memories of elephants -- quite appropriate given that the elePHant is the official mascot of the PHP project.1 point
-
I have no idea how your chart software works but if you provide five data values (8, 19, 11, 3, 49) for one type and three data values (1, 3, 7) for the other, how is it supposed to know which months those values are for? You have a very weird x-axis for that chart (the month sequence is 6-5-4-3-2-1-12-11-10-9-8-7). The norm is to put them in chronological order.1 point
-
Have you triedd using xpath()? <?php $str = '<xml><chapter num="17"> <verse num="1">And after six days Jesus taketh Peter, James, and John his brother, and bringeth them up into an high mountain apart,</verse> <verse num="2">And was transfigured before them: and his face did shine as the sun, and his raiment was white as the light.</verse> <verse num="3">And, behold, there appeared unto them Moses and Elias talking with him.</verse> <verse num="4">Then answered Peter, and said unto Jesus, Lord, it is good for us to be here: if thou wilt, let us make here three tabernacles; one for thee, and one for Moses, and one for Elias.</verse> <verse num="5">While he yet spake, behold, a bright cloud overshadowed them: and behold a voice out of the cloud, which said, This is my beloved Son, in whom I am well pleased; hear ye him.</verse> <verse num="6">And when the disciples heard <i>it,</i> they fell on their face, and were sore afraid.</verse> <verse num="7">And Jesus came and touched them, and said, <span class="j">Arise, and be not afraid. </span></verse> <verse num="8">And when they had lifted up their eyes, they saw no man, save Jesus only.</verse> <verse num="9">And as they came down from the mountain, Jesus charged them, saying, <span class="j">Tell the vision to no man, until the Son of man be risen again from the dead. </span></verse> <verse num="10">And his disciples asked him, saying, Why then say the scribes that Elias must first come?</verse> <verse num="11">And Jesus answered and said unto them, <span class="j">Elias truly shall first come, and restore all things. </span></verse> <verse num="12"><span class="j">But I say unto you, That Elias is come already, and they knew him not, but have done unto him whatsoever they listed. Likewise shall also the Son of man suffer of them. </span></verse> <verse num="13">Then the disciples understood that he spake unto them of John the Baptist.</verse> <verse num="14">And when they were come to the multitude, there came to him a <i>certain</i> man, kneeling down to him, and saying,</verse> <verse num="15">Lord, have mercy on my son: for he is lunatick, and sore vexed: for ofttimes he falleth into the fire, and oft into the water.</verse> <verse num="16">And I brought him to thy disciples, and they could not cure him.</verse> <verse num="17">Then Jesus answered and said, <span class="j">O faithless and perverse generation, how long shall I be with you? how long shall I suffer you? bring him hither to me. </span></verse> </chapter></xml> '; $xml = simplexml_load_string($str); $verses = $xml->xpath('//verse'); ?> <!DOCTYPE html> <html lang='en'> <head> <title>XML example</title> <meta charset='utf-8'> <style type='text/css'> .j { color: blue; font-style: italic; font-weight: 600; } </style> </head> <body> <?php foreach ($verses as $v) { echo "<p>{$v->asXML()}</p>"; } ?> </body> </html> Gives...1 point
-
This is a common pattern, where you have a script that renders a form and also processes it. phppup provided a few great examples of how to handle it. Sometimes people will also choose to use the ability of PHP to provide you the HTTP method, given that you only want to process the form when the HTTP method was a POST. if ($_SERVER['REQUEST_METHOD'] === 'POST') { // This was a POST request. } However, with all that said, looking at your actual code, which I have put in the code block below, your code already should have been working, because it already evidently did what phppup demonstrated: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Untitled 1</title> </head> <body> <form method="post"> <input type="text" name="firstName" placeholder="First Name" value="first name"> <br> <input type="text" name="lastName" placeholder="Last Name" value="last name"> <br> <input type="submit" name="submit" value="Submit"> </form> <?php echo "running script"; if(isset($_POST['submit'])){ $firstName = "First Name:" . $_POST['firstName']. ""; $lastName = "Last Name:".$_POST['lastName'] . ""; $file = fopen("file.txt", "a"); fwrite($file, $firstName); fwrite($file, $lastName); fclose($file); } ?> The ONLY issue here, is that your script echos out "running script" regardless. If you moved that echo statement inside the if loop, you would perhaps not be fooled into thinking the code that you did not want to be run was running. In summary, your code already worked, but your debugging statement displayed even when the processing was not being run. One thing I would like to suggest to you, is that you can take advantage of variable interpolation. It is one of the things that makes PHP very nice to work with, not unlike the introduction of template literals in javascript. You have this concatenation: $firstName = "First Name:".$_POST['firstName'].""; But with interpolation, you can use the much more natural and simpler to read, debug and modify: $firstName = "First Name:{$_POST['firstName']}"; Interpolation is done anytime you utilize double quotes. It's good practice (although a micro optimization) to use single quotes anytime you want a string constant. When PHP sees double quotes around a string it will try to interpolate. With single quotes, it will not. $name = 'Gizmola'; echo "Hello $name <br>"; \\ output: Hello Gizmola <br> echo 'Hello $name <br>'; \\ output: Hello $name <br> I'm not sure why you originally had the extra "", which essentially does nothing, as the code is saying "add nothing to the end of this string." You can add things like newlines using escape characters. A newline character can be added using "\n". $firstName = "First Name:{$_POST['firstName']}\n"; Similar escape characters like tab can be inserted using this technique (in an interpolated string). Last but not least, you only need to enclose the variable inside a block ie, {variable}, when the variable is an array element, as in the case of the $_POST. Without putting the { .. } around the array variable, PHP is not able to parse the string properly, and you get a syntax error. Putting the block around array variables solves the problem. With simple php variables like "$name" you can just use them inside the double quoted string, and PHP will interpolate them into the resulting string variable. One of the strengths of PHP for web development is its HTML/PHP block modality, which you are using here. Before long, however, you likely want to have something like a header.php you include in scripts, so you aren't cutting/pasting the same HTML block into each script. Along these lines, PHP also has HEREDOCS which support interpolation. So you could move all of the your HTML boilerplate into a PHP script. In your case, at least trivially, you would want to have the page title be a variable, in this case $title. //htmlHead.php <?php $htmlHead = <<<HEADER <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>$title</title> </head> HEADER; Note a few things here: You do not ever need to have an ending PHP tag in your scripts, class files or function collections. The only time you need to use a php end tag (?>) is if you are dropping in and out of PHP mode. So now we can rewrite your original script this way: <?php $title = 'Name File Processing'; require_once('htmlHead.php'); echo $htmlHead; ?> <body> <form method="post"> <input type="text" name="firstName" placeholder="First Name" value="first name"> <br> <input type="text" name="lastName" placeholder="Last Name" value="last name"> <br> <input type="submit" name="submit" value="Submit"> </form> <?php if(isset($_POST['submit'])){ echo "running script<br>"; $firstName = "First Name: {$_POST['firstName']}"; $lastName = "Last Name: {$_POST['lastName']}"; $file = fopen("file.txt", "a"); fwrite($file, $firstName); fwrite($file, $lastName); fclose($file); } ?> </body>1 point
-
I don't know what you were doing in those screenshots but it sure doesn't look like you tried running "python app.py".1 point
This leaderboard is set to New York/GMT-05:00