Jump to content

CyberShot

Members
  • Posts

    322
  • Joined

  • Last visited

Everything posted by CyberShot

  1. ok, I got the session_start to work, but it echoes $fstring to the screen instead of the number of hits. I have an index page that I have incuded page one into and I put the session start there. Now I am not getting any errors, I am just not getting the value of the variable. page 1 <?php $filename= "reader.txt"; $fd = fopen ($filename , "r") or die ("Can't open $filename"); $fstring = fread ($fd , filesize ($filename)); $_SESSION['pageHits'] = '$fstring'; fclose($fd); $fd = fopen ($filename , "w") or die ("Can't open $filename"); $fcounted = $fstring + 1; $fout= fwrite ($fd , $fcounted ); fclose($fd); ?> page 2 <?php session_start(); ?> <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php echo $_SESSION['pageHits']; ?> </body> </html>
  2. I get an error that says Cannot modify header information - headers already sent by (output started at /counter/index.php:9) in counter/counter.php on line 10 which is this header("Location: ./display/index.php$variable=$fstring");
  3. interesting. i will try that right now.
  4. I have this script for a web counter. I did not write it, I followed a tutorial. I am trying to learn how to use the information in another script. The idea is to have the web counter on a page but send the results to a different page. I have already set up a method of doing this by just reading the file again on the page I want the results. But I thought there might be a better way. Some say use sessions, But I have never done this and when I tried, it didn't work for me. Here is the code I have now. I want to send $fstring to another page $filename= "reader.txt"; $fd = fopen ($filename , "r") or die ("Can't open $filename"); $fstring = fread ($fd , filesize ($filename)); fclose($fd); $fd = fopen ($filename , "w") or die ("Can't open $filename"); $fcounted = $fstring + 1; $fout= fwrite ($fd , $fcounted ); fclose($fd);
  5. I found a simple form that works. I will modify it to my needs <form name="form" method="post" action="testform.php"> <p class="bodymd">Your Name<br> <input type="text" name="Name"> </p> <p class="bodymd">Your Email<br> <input type="text" name="Email"> </p> <p class="bodymd">Comments or Questions<br> <textarea name="Comments" rows="5" cols="40"></textarea> </p> <p class="bodymd"> <input type="submit" name="Submit" value="Submit"> <input type="reset" name="Reset" value="Clear Form"> </p> </form> <?php if (($Name == "") || ($Email == "") || ($Comments == "")) { echo "<form name=form method=post action=contact_thanks.php>"; echo "<p class=bodymd>All three fields of this form are required, I really don't think that's too much to ask...</p>"; echo "<p class=bodymd>Fill in the ones you missed, they are listed below.</p>"; } if ($Name == "") { echo "<p class=bodymd>Your Name<br><input type=text name=Name></p>"; } else { echo "<input type=hidden name=Name value=$Name>"; } if ($Email == "") { echo "<p class=bodymd>Your Email<br><input type=text name=Email></p>"; } else { echo "<input type=hidden name=Email value=$Email>"; } if ($Comments == "") { echo "<p class=bodymd>Comments or Questions<br><textarea name=Comments rows=5 cols=40></textarea></p>"; } else { echo "<input type=hidden name=Comments value=$Comments>"; } if (($Name == "") || ($Email == "") || ($Comments == "")) { echo "<input type=submit name=Submit value=Submit>"; echo "<input type=reset name=Reset value=Clear Form>"; echo "</form>"; } else { $message = "Name: $Name\nEmail: $Email\nComments: $Comments\n"; $extra = "From: $Email\r\nReply-To: $Email\r\n"; mail ("my-email.net", "mail subject goes here", $message, $extra); echo "<p class=bodymd>Thanks for your inguiry, $Name.</p>"; echo "<p class=bodymd>A response will be sent to $Email as soon as possible.</p>"; } ?>
  6. I will try it again with real values
  7. it printed this to the browser Array ( [name] => adf [email] => adf [gender] => M [contact] => y [comments] => ad [submit] => Send ) of course, I just pushed buttons that don't mean anything. just to put something in the fields
  8. I have tested the script above and it works for my email. I usually get it instantly. but when I try using that script on my form rather than the form I got it with. it fails. The $_POST didn't work.
  9. no I changed it for posting purposes.
  10. I have been googling this stuff for a while, I also have been going through a book. I have also been looking at other forms that I know work. forms that I am using right now at this very min on another site. here is the code for that form <?PHP $email = $HTTP_POST_VARS[email]; $mailto = "my-email.net"; $mailsubj = "information from mysite.com"; $mailhead = "From: $email\n"; reset ($HTTP_POST_VARS); $mailbody = "Values submitted from mysite.com :\n"; while (list ($key, $val) = each ($HTTP_POST_VARS)) { if ($key!="submit") { $mailbody .= "$key : $val\n"; } } mail($mailto, $mailsubj, $mailbody, $mailhead); ?> So I figured that I could keep the same pattern and all would be well. when I look at what you posted above, it makes no sense because it first, I am a very new to php and second, it doesn't follow the same logic that the web and the books are telling me. I am trying to get it right as you posted
  11. yes, I do have a problem somewhere, just trying to figure out where. I have been trying to add stuff from that link you gave me, but it don't seem to be working.
  12. I don't get any error messages when I send the form.
  13. I have other forms on the server that work just fine. thought my form might just be missing something
  14. I am trying to make a form for a church website. for prayer requests. I need the form to be sent over email. I filled out the form and all went as expected, but I didn't get an email. Can you check it out to see what I did wrong? The form <form action="handle_form.php" method="post"> <fieldset> <legend>Enter your prayer request below</legend> <p>Name:</p> <input type="text" name="name" id="name" /> <p>Email:</p> <input type="text" name="email" id="email" /> <p>Gender:<input type="radio" name="gender" value="M" />Male <input type="radio" name="gender" value="F" />Female</p> <p>would you like to be contacted?</p> <select name="contact"> <option value="y">Yes</option> <option value="n">NO</option> </select> <p>Your Prayer Request:<br /><textarea name="comments" rows="10" cols="40"></textarea></p> </fieldset> <div><input type="submit" name="submit" value="Send"/> </div> </form> the code to handle the form <?php if(!empty($_REQUEST['name'])) { $name = $_REQUEST['name']; } else { $name = NULL; echo "Please put in your name"; } if(!empty($_REQUEST['email'])) { $email = $_REQUEST['email']; } else { $email = NULL; echo "Please put in your email"; } if(!empty($_REQUEST['comments'])) { $comments = $_REQUEST['comments']; } else { $comments = NULL; echo "Please add some comments"; } if(isset($_REQUEST['contact'])) { $contact = $_REQUEST['contact']; if($contact == 'y') { echo 'we will contact you shortly'; }elseif ($contact == 'n') { echo 'you will not be contacted'; } else { $contact = NULL; echo 'you should say yes or no to being contacted'; } } $mailto = "my-email.net"; mail($mailto, $name, $email, $contact, $comments); or die("failure"); ?>
  15. yes, I did. I told you that I don't know a lot about php. That is why I asked the question. It's good that you know that is what it is for or that it was built to handle such things. But I didn't know that. That's why I asked the question. I had read other posts that said php couldn't handle some things. I don't know for sure what the extent of it's math capabilites are. That's why I asked if it could do it. I hope one day to be a php guru, but that day isn't today.
  16. i posted above why I asked the question
  17. I am running wamp on my computer at home. I am a freelance web designer. I was thinking about trying to build a database on my system that I could use to keep track of customers, print invoices and calculate the amount owed based on the time spent working on a project and then be able to email my customer the invoice by pushing a button. My question is this. How difficult would it be to use php to do this job? I don't know a lot about php right now, so it would take some time to build. Do you think php could handle the job?
  18. I tried removing the '. and I got an error, so I put the ' back in and it worked. So instead of id='. $subject I got id=' $subject and now it works. Thanks for the help
  19. Do you see anything wrong with this query? $query = "SELECT * FROM subjects WHERE id=' . $subject_id' LIMIT 1";
  20. didn't even think to view the source code of the page. Another great idea. Wow, you are just batting them out of the park tonight! LOL
  21. Oh! I get it! Wow! I never would have spotted that. I knew about spacing from concatinating (spell check) things, but I didn't have any idea that was what was going on here. Thanks for that. That info should come in handy in the future
  22. Thank you very much. I spotted it. I didn't think the space after the quote on the echo " class=\"selected\" would make a difference. It actually fixed three problems I was having. So you fixed three in one, Nice shot.. Thanks for your help. I appreciate it. Now can you tell me why adding a space after a quote fixed the problem?
  23. I may have been staring at this code for to long. I don't see a difference. What do you mean "Do you see the class="selected" "?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.