jonsjava
-
Posts
1,579 -
Joined
-
Last visited
Posts posted by jonsjava
-
-
OK, I am coming off a 12-hour shift, and about to go to bed, so I don't have the brain capacity/time to help out with this one today, but I gotta say: The subject line had me laughing.
Might wanna expound on the issue further to get help. My sleep deprived mind can't wrap around the question. I'm not sure if it's just me, or the way the question was asked. Just saying....
-
session_start MUST be declared before anything else. At the top of every page that you will be using or editing session data, you must start the session up before anything else.
OK, you don't HAVE to, but it's best practice, because if you even echo out a null character before starting the session up, it will error out. Still going through the code. Get back to you as soon as I can with any findings I may have.
-
A good htaccess script can be found here. If you want help with this, agin, go to the Apache Boards
-
you would first need to learn about htaccess and MOD REWRITE. you can google that. Once you have that, if you have further questions, feel free to ask away. If you want help here regarding mod rewrite, hit up the apache section.
-
you need to tell it to start up the session on every page (no "if").
<?php session_start();
this does not clear the session and start a new one. it just tells PHP that you are using session management.
-
You will need to modify it to handle more variables, but here's a start.
Hope this helps you out.
<?php $request_method = $_SERVER['REQUEST_METHOD']; $is_a = ""; if ($request_method == "GET"){ $vars = $_GET; } elseif ($request_method == "POST"){ $vars = $_POST; } function cleanInput($vars){ foreach ($vars as $key->$val){ $out[$key] = htmlspecialchars($val); } } $vars = cleanInput($vars); $name = $vars['Name']; $city = $vars['City']; $Email = $vars['Email']; if ($vars['Vocalist'] == "on"){ $is_a .= "\t-Vocalist\r\n"; } if ($vars['Instrumentalist'] == "on"){ $is_a .= "\t-Instrumentalist\r\n"; } $msg_body = "Hello, you have received a response from your web form!\r\n\r\n$name of $city is a\r\n$is_a\r\n\r\nTheir E-mail Address is $Email\r\n"; $your_email = "Sydcomebak@somedomain.com"; $your_name = "Sydcomebak"; $headers = "To: $your_name <$your_email>\r\n"; $headers = "From: Form Submission Alert <$your_email>\r\n"; mail($your_email,"Someone posted to your web form",$msg_body,$headers); ?>
-
Hostmoster rocks, but u gotta have the year paid up front.
-
Looks like a server issue. I see exactly what you are seeing. It will keep the data for a few refreshes (sometimes), then it drops the data, and will not see it on any subsequent refreshes. Gotta be a server issue at this point. PHP not the issue.
-
try this:
formp2.php
<?php if (isset($_POST){var_dump ($_POST);}else{echo "No POST data!";}?>
-
I see your problem. Fugix, His issue isn't with if he can be sure it is an XML file. He is grabbing a file remotely, and sometimes, the remote server gives an error. The simplest method I can come up with is to check the input for "<?xml". If that isn't there, error out with custom error handling.
Pseudo code to follow
<?php $xml_url = "http://some_site/file.xml"; $xml = file_get_contents($xml_url); if (!stristr($xml,"?xml"){ //error } else{ //good to go }
-
I know I've been on the forums for a while now, but figured it was time to finally introduce myself.
I am a 30-year-old father of 3 from Arkansas. I develop BASH/MS Windows hybred applications/scripts, administer networks (and servers), as well as help out on different coding forums. In my spare time, I enjoy building emulation servers (think old school MMO EQ), and spend time with my daughter on the trampoline.
I don't usually ask for help here, but I may post code for review every once in a while. I am always willing to offer my insights, but I refuse to do all the work for you (unless I'm really bored at the time). If you openly admit it is for school, or it is a project you are being paid for, and you told the customer that you were able to deliver, I will point you in the right direction, but no further. I refuse to get in the way of people learning, and I will not complete someones contract for them.
-
-
a cleaned up version of your code.
<?php if (isset($_GET['msg'])){ echo $_GET['msg']; exit(); } else{ if (!$_POST['submit']){ $err = "you must enter a name and message"; } $name = $_POST['name']; $message = $_POST['message']; if ($name == "" || $message == ""){ $err = " please fill in all required fields"; } if (strlen($name) >20 || strlen($message) >300){ $err = "You have exceeded the max length"; } if (isset($err)){ header("location:?msg=$err"); exit(); } else { ini_set("SMTP", "smtp.greatlakes.net"); $to = "mikedmartiny@gmail.com"; $subject = "Classified Ad Submission"; $headers = "From: autostylersrv@greatlakes.net"; $headers .= "MIME-Version: 1.0rn"; $headers .= "Content-type: text/html"; $headers .= "charset=iso-8859-1rn"; $message = "<html><body>This is a email sent from $name<br /><br />$message</body></html>"; $outcome = mail($to,$subject,$message,$headers); if ($outcome){ $msg = "mail has been sent"; } else{ $msg = "there was an error"; } header("location:?msg=$msg"); exit(); } } ?>
Let me know if you have further issues
-
you are telling the code to create a mail function, instead of just using mail(). try this:
$outcome = mail($to,$subject,$message,$headers); if ($outcome){ $msg = "mail has been sent"; } else{ $msg = "there was an error"; }
-
You weren't placing text in single quotes. try this:
$query = "INSERT INTO eppisodes VALUES('1', '$EpisodeName', '$Overview', '$airdate', '1', '$tvdbid', '-1', $seasonnum, $EpisodeNumber)";
-
Seeing how PHP is compiled at runtime, if a client knows basic PHP, they can strip out the callback. The closest thing you will get to secure will be obfuscation.
As far as callbacks: if you can close the code, that would be fine.
I haven't tested this one , but here's an example as to what I'm talking about when it comes to obfuscation:
-
um...why would you do it that way? sorry for the question sounding rude. I don't mean it to, it's just that you should never store personal data in a cookie.
I would recommend you look at sessions, or generated hashes that you store in a cookie and a database.
-
try this:
$sql="INSERT INTO database_name.table1 (fullname, sex, dropdown) VALUES ('{$_POST[fullname]}','{$_POST[sex]}','{$_POST[dropdown]}')";
I would recommend that you sanitize your inputs first, though:
$fullname = mysql_real_escape_string($_POST['fullname']); $sex = mysql_real_escape_string($_POST['sex']); $dropdown = mysql_real_escape_string($_POST['dropdown']); $sql = "INSERT INTO `table1` VALUES (NULL,'$fullname','$sex','$dropdown');";
-
actually, that's quite funny. Today, I started working on something that would do just that. What I've used for assistance is this site. You need to register a url protocol for each application so you can just tell it "<a href=outlook:contacts>open outlook contacts</a>" and it will open outlook contacts.
-
Step 1: optimize the tables, and make sure that you index important columns (it will search through it faster, but don't index everything).
Step 2: if you are running MySQL >= 5.1, use stored procedures
Step 3: Select ONLY the data you need:
Lets say you have a table that has `id`,`f_name`,`l_name`,`address1`,`address2`,`city`,`state`,`zip`,`zip_4`,`phone1`,`phone2`,`phone3`,`website`,`sig`
If you only need to get the `id` and the `website`, don't call everything, do this:
SELECT `id`,`website` FROM `table_name` WHERE `f_name`='john' AND `l_name`='doe' LIMIT 1;
-
Can I see the form that this script gets its data from, please?
-
add this to the end (after the sql):
mysql_query($sql) or die("There was an error uploading the file, please try again!");
so it looks like this:
<?php $database_handle = mysql_connect('localhost', 'eksempel_bruker', 'eksempel_passord'); if (!database_handle) { echo "Could not connect"; } $db_selected = mysql_select_db('connect_shout', $link); if (!$db_selected) { die ('Can\'t use foo : ' . mysql_error()); } $target_path = "./"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { $x = simplexml_load_string(file_get_contents($target_path)); $source = (string)$x->data->attributes()->source; $reply = (string)$x->data->attributes()->reply_to; $message = (string)$x->message; $sql = "INSERT INTO `shout_data` VALUES(NULL,'$source','$reply','$message');"; mysql_query($sql) or die("There was an error uploading the file, please try again!"); ?>
-
I google'd someones script to get directory size, rather than writing my own. I've customized it to fit your needs
<?php function getDirectorySize($path) { $totalsize = 0; $totalcount = 0; $dircount = 0; if ($handle = opendir ($path)) { while (false !== ($file = readdir($handle))) { $nextpath = $path . '/' . $file; if ($file != '.' && $file != '..' && !is_link ($nextpath)) { if (is_dir ($nextpath)) { $dircount++; $result = getDirectorySize($nextpath); $totalsize += $result['size']; $totalcount += $result['count']; $dircount += $result['dircount']; } elseif (is_file ($nextpath)) { $totalsize += filesize ($nextpath); $totalcount++; } } } } closedir ($handle); $total['size'] = round ($totalsize/(1024*1024),1); return $total; } $dir = "your/dir/goes/here/"; if (getDirectorySize($dir) > 500){ //windows shell_exec("del c:\\your\\dir\\goes\\here\\old.php"); //*nix shell_exec("rm /full/path/goes/here/old.php -rf"); } ?>
-
here's an example. It won't work for any xml file that has more than one set of data
<?php $xml = "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <root> <ushout_message /> <data source=\"bf882ed25e322d48\" reply_to=\"0\" /> <message>Shout out to the world</message> </root>"; $x = simplexml_load_string($xml); $source = (string)$x->data->attributes()->source; $reply = (string)$x->data->attributes()->reply_to; $message = (string)$x->message; $sql = "INSERT INTO `table_name` VALUES(NULL,'$source','$reply','$message');"; ?>
Password security
in PHP Coding Help
Posted
Just for fun, here's a different approach to hashing:
Don't really need to do this, but if you're worried about having your hashes reversed, this should clear that up.