Jump to content

dekonstruct

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dekonstruct's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, I've got a form that is built using php. It counts backwards from todays date to zero and each number is a selection. I then pass this number variable to another page called num.php I was wondering if there's a way to get rid of that submit button and still be able to pass my php variables to num.php. I've tried some things in javascript but it didn't pass the php variables along with it. Here's the code for the form: <form method="post" action="num.php"> <select name="num"> <?php $y = date('z') + 1; for($x = 1; $x < $y; $x++) { print "<option>$x</option>\n"; } ?> <input type="submit" value="submit" name="submit"> </select> </form> Here's the code on num.php in case you need it: <?php session_start(); $_SESSION['dailies'] = $_POST["num"] - 1; ?> Many thanks in advance.
  2. I first define $_SESSION['dailies']; in the else part with: [code]$_SESSION['dailies'] = $date + $_SESSION['counted'];[/code] It's so that when the page first loads it's at 0 and when it refreshes it counts down from the day. If there's a better way to do it I'm all ears, it feels like an ineloquent solution but I'm still learning obviously. Thanks!
  3. I'm having problems setting $_SESSION['dailies'] back to the date when it gets to 0. Here's my code: [code]<?php session_start(); $date = date('z'); ###counter### if(isset($_SESSION['counted'])){ $new = $_SESSION['counted'] - 5; $_SESSION['counted'] = $new; }else { $_SESSION['counted'] = 0; } ######### ### supposed to set counter back to date ### if ($_SESSION['dailies'] <= 0) { $_SESSION['dailies'] = date('z'); } else { $_SESSION['dailies'] = $date + $_SESSION['counted']; echo $_SESSION['dailies']; } ?> [/code] I think it might have something to do with the placement of my if statement in the code but I've tried it both before and after the counter function. BAH! Any help and I'll love you forever. (in a non brokeback kind of way).
  4. cool, another good reason to use php! thanks guys!
  5. Hi, I was wondering how to go about setting variables within a hyperlink. Here's the php part of what I'm trying to do (forgive my clunky code): [code] $_SESSION['date'] = date('z'); $counter = 0; $_SESSION['nav'] = "c"; switch($_SESSION['nav']){   case b:     echo "forward";     $counter = $counter + 1;    break;     case a:     echo "backward";     $counter = $counter - 1;     break;     default:     echo "nowhere"; } $_SESSION['dateprint'] = date('z') + $counter; ?> [/code] and I'm trying to set the $_SESSION['nav'] variable within a hyperlink, and I've tried a couple of different ways that don't work. examples: [code] <a href="index.php?nav=a;> <a href="index.php?_SESSION[nav]=b;"> [/code] any help would be greatly appreciated thanks!
  6. Low and behold I finally found a fix to my problem. I found it here:[url=http://us2.php.net/function.session-start]http://us2.php.net/function.session-start[/url] Turns out that when you edit it in notepad, you shouldn't select utf-8 encoding because it puts two hidden characters before the document starts, thus you can't start a session. everything works beautifully for me, thanks everyone for your help! here's what the smart dude that found this out said: [quote] saykyo (mail at gmail dot com) 12-Jul-2006 08:23 Watch out for using UTF-8 encoding in your php scripts! I don't know about other enviroments, but in Windows XP, if you edit a document and set it to be UTF-8, the editor (notepad for exapmle) inserts two invisible bytes at the beginning of the file (they read FF FE in hex for me). I suppose this happens so Windows can identify the file as UTF-8. Since these two bytes are placed before anything else in the file, including <? ?> tags, when you execute the php script, they get outputed to the browser (even tough they won't be shown in the source of the result document, they're there!) before your php code gets a chance to run anything. This effectively cripples functions like session_start() ($_COOKIE to be exact). The solution is to save the php file in a different encoding, or to manually remove them (I prefer the former). I hope I helped somebody. [/quote]
  7. I was wondering if it is possible to put an inputed e-mail address into the subject line of an e-mail that is generated by a form. Here's part of the code where it might be possible: [code]<form action="/cgi-bin/formmail" method="post" id="contactForm" name="contactForm"> <input type="hidden" name="required" value="FirstName,LastName,Email,Company,JobTitle,Phone,Preference" /> <input type="hidden" name="sort" value="FirstName,LastName,email,Company,JobTitle,JobResponsibilities,Address,Address2,CityTownVillage,StateProvince,ZipPostal,Phone,Preference,Time,IntendedUse,QuestionsComments" />     <input type="hidden" name="subject" value="xxxxx Contact Form," />     <input type="hidden" name="recipient" value="xxxxxxx" />     <input type="hidden" name="redirect" value="xxxxx" />     <fieldset style="padding: 10px;">     <legend style="margin-left: 180px; padding-left: 10px; padding-right: 10px;">       <strong>(<span class="required">*</span>) indicates required field.</strong>     </legend>     <br />     <label for="FirstName">First Name <span class="required">*</span>:</label>     <input name="FirstName" id="FirstName" type="text" class="textfield_medium" />     <br />     <label for="LastName">Last Name <span class="required">*</span>:</label>     <input name="LastName" id="LastName" type="text" class="textfield_medium" />     <br />     <label for="Email">E-mail <span class="required">*</span>:</label>     <input name="Email" id="Email" type="text" class="textfield_medium" />     <br /> [/code] thanks!
  8. it would seem I'm running php 4.4.1 on a linux/apache server. would there be something with my server restricting sessions?
  9. that code was actually embedded in a different page in the main body of some html. Oddly enough that code worked fine, but it was simple enough I guess. I am trying to figure out what flavor of php is installed on what kind of server at my host, methinks that might be the culprit.
  10. nope absolutely nothing before it. I used notepad in WinXP maybe it needs to be a certain type of encoding?
  11. [code]<?php session_start(); if(isset($_SESSION['counted'])){ $new = $_SESSION['counted'] + 1; $_SESSION['counted'] = $new; echo $_SESSION['counted']; }else { $_SESSION['counted'] = 1; } ?>[/code] I just cut and pasted what mgallforever had posted... there's nothing else on the page, and it's called phptest.php here's the error: [b]Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /xxx/xxx/xxx/xxx/xxx/xxx/xxx/test/phptest.php:1) in /xxx/xxx/xxx/xxx/xxx/xxx/xxx/test/phptest.php on line 2[/b] sorry if this all seems too easy... The only language-ish thing I've known before trying php was actionscript so I'm a little broken  ;)
  12. hmmm sessions seem to be what I need. I tried one out and got this error: Warning: session_start(): Cannot send session cookie - headers already sent by... I don't see how anything is being sent when there's only one session on the darn page. I am viewing this off a server through firefox if that's any help to anyone. do i need to setup my server differently to be able to handle sessions perhaps? Thanks everyone!
  13. Hello, I'm quite a noob at all this php stuff, here's my problem: I have some simple strings: <?php $day = date(z); $counter = 1; echo $day; echo $day - $counter; ?> and I'm wondering how to create a link that adds 1 to the counter everytime you click it. I know that ++ is incremental but php in links completely baffles me at the moment. any prodding in the right direction would be most appreciated. THANK YOU!
×
×
  • 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.