
davidannis
Members-
Posts
627 -
Joined
-
Last visited
-
Days Won
2
Everything posted by davidannis
-
Last time that happened to me it turned out that the servers IP address had ended up an a blackhole list. Have you checked to make sure outgoing mail from that server not generated in php reaches you?
-
I'd consider using a <select> to input the integer instead of a text field.
-
$maxfields=intval($POST['add_field']); for ($i=1; $i<=$maxfields; $i++){ echo $i.'<input type="text" name="option_"> '.'<br>'; with html that looks like: <input name="add_field" type="text">
-
Delete database row's whit php button
davidannis replied to HcWestergaard's topic in PHP Coding Help
$query="DELETE FROM `mydatabase` WHERE 1"; $reslut = mysqli_query($link, $query); you need to connect to your database first, maybe validate the input, but that should get you started. -
or you can do what you tried with echo $i.'<input type="text" name="option_'.$i.'">'
-
You can have multiple field with the same name by using [] <input type="text" name="myname[]" you can fill the brackets with your values of $i or leave it blank.
-
What is the file extension? Should be .php Can you post the entire command used to run the program. Are you sure that you are executing the correct file because if you added a line at the top <?php then the line at which the error occurs should move down one line?
-
Can I define a session variable before session_start()?
davidannis replied to suckerpunch's topic in PHP Coding Help
I believe that you can put the session_start below the first line AS LONG AS you have no output to the browser before the session_start. If you have output to the browser then the header has already been sent and you get an error to that effect so it is usually good practice to put it right at the top. -
works for me as posted. Do you have <?php at the top and ?> at the end?
-
I'm guessing the source of his confusion is that he is developing using WAMP or MAMP and so his machine is both the server and the client. I don't think that the session_id can be based on the IP because you can not rely on an IP to be static for a browser. May not be an issue in modern times but I certainly remember trying to do sessions based on IP in the good old day and having AOL send every page request for a user from a different IP address. You could manually store and check User Agent to tighten things a bit, you can also provide a logout fuction to users that destroys the session. unset($_SESSION); session_destroy(); should do it.
-
Can you post more of the code than that? Please put code in code tags.
-
You can verify what Barand said is true with: $testme= gettype($uwa) echo $testme; if ($testme=='array') { print_r($uwa); }
-
php include relative or absolute path
davidannis replied to Renidrag's topic in Editor Help (PhpStorm, VS Code, etc)
Not sure about Dreamweaver, but I have a convention of having three servers dev.mydomain.com, test.mydomain.com, and the live server. I include a config.php that looks at the URL and defines paths, directories, database connections, etc. for each environment. -
Paul Ryan is absolutely correct. The reason is that the session_start() wants to read/set a cookie with a session identifier. If the script has already started to output back to the browser it has already sent the header which should contain the cookie.
-
<form action="myfolder/myphpfilename.php" method="POST"> <input type="text" name="myfieldname"> .... many more fields here if you need them. <input type="submit"> </form> To see something when you access your php file you need the php to output something. Try adding this code echo 'Hi there <br />'; echo $_POST['myfieldname']; to see how it works.
-
If I were in your shoes I'd look at the page source to see if the whole output is somehow in a tag or comment or something and then start putting echo "1234"; die(); at different points in my script to see how far it made it. I'm sure that there are more elegant ways to tackle the problem.
-
It may be a permissions problem. What are the permissions on your main directory and the subdirectories? On the files in main directory and in the subdirectories?
-
email address from form submission to appear in "From"
davidannis replied to mark60480's topic in PHP Coding Help
You need a . (period) between the email'] and the "\r -
Why not use 4 characters that are sequential (0-9a-z) followed by four random characters. No need to check the database. No repeats. 36^4 combinations = 1,679,616. If you need more combinations add upper case or special characters.
-
Need to insert a cc in my PHP form to email script
davidannis replied to lanacaralee's topic in PHP Coding Help
right below the line $headers = "From: " . $from_email; add a line $headers .= "Cc: " . $cc_email; where $cc_email contains the address you want to cc. May also want to change if ($from_email) to if ($from_email || $cc_email) in case you ever change the hard coded from address to be blank or you could just get rid of the if entirely. -
FWIW, in an effort to avoid all possible productive work I looked at how long it took to set the year in a database using 3 methods, php outside of the loop, php every time the data was written and using the db's native function. The native function is a tiny bit more efficient unless you are going to make multiple writes tot he DB (you can't pull the native MySQL function out of the loop). The code: <?php require_once 'config.inc.php'; require_once (NON_WEB_DIR.'setup.php');; $time = -microtime(true); for ($i=0; $i < 4000; ++$i) { $c=date('Y'); $query = "INSERT into test (`id`,`year`) VALUES ('','$c')"; $result= mysqli_query($link, $query); } $time += microtime(true); echo "time: ",sprintf('%f', $time),PHP_EOL; $c=date('Y'); echo '<br />time set outside of loop'; $time = -microtime(true); for ($i=0; $i < 4000; ++$i) { $query = "INSERT into test (`id`,`year`) VALUES ('','$c')"; $result= mysqli_query($link, $query); } $time += microtime(true); echo "time: ",sprintf('%f', $time),PHP_EOL; echo "<br />time set by DB"; $time = -microtime(true); for ($i=0; $i < 4000; ++$i) { $query = "INSERT into test (`id`,`year`) VALUES ('',NOW())"; $result= mysqli_query($link, $query); } $time += microtime(true); echo "time: ",sprintf('%f', $time),PHP_EOL; ?> the results: time: 0.272242 time set outside of looptime: 0.242826 time set by DBtime: 0.268353
-
Joseph's original question was so I assume that he is. I have no idea why.
-
Jessica, If I understand correctly, you are saying create a table with a column called myfieldname, YEAR(4) and then INSERT into `mytablename` (myfieldname) VALUES (NOW()) What difference does it make? Is it a security issue or an efficiency issue or something else entirely?
-
joseph $c_date = date ("Y"); $query="INSERT into mydatabase ('myfieldname') VALUES ('$c_date')"; then execute the query
-
$email=htmlentities($_POST['email']); mail ( '[email protected]' , 'Another Email address from my website' , $email); might want to include a thank you message too.