|
hi, i have created a member log in system which will change a page which is included on the homepage....
Ok, now when i log out it destroys the session fine but then i get this error
"Notice: Undefined index: logged in ttab.php on line 4",
how do i get rid of the error because on other pages it seems to go away ...
Code for file which displays depending on session ... (ttab.php)
<html><style>div{font-family:Arial;}</style><body>
<?php
session_start();
if (!($_SESSION['logged']== true))
{
echo"<a href='memlogin.php?msg=0' id='flink'><div>Register/Log In</div></a>";
}else{
$name = $_SESSION['user'];
echo"Welcome $name,  <a href='account.php' id='flink'>Account Options</a> | <a href='ref/logout.php'id='flink'>Log Out</a>";
}
?>
</body></html>
Process that the log out does ... (logout.php)
session_start();
session_destroy();
header("location: ../index.php");
|
|
|
|
|
The "undefined index" message is telling you that there is no value with the key 'logged' in $_SESSION .
Try changing your test to this:
if (!(isset($_SESSION['logged']) && $_SESSION['logged']== true))
The isset call will short-circuit the test if the 'logged' key is not found.
|
|
|
|
|
I'm new to PHP so please excuse my ignorance here. I'm in the process of learning PHP on my own and need to get a new book (only have one on PHP 3 ). What I'm looking for is how to pass "variables to pages" I think? From what I can tell in my limited exp this is possible just not sure what it's called. For example in a URL you may see something like CalDateMonth=12 or something similar to that, don't have a exact example at the moment. So when I look for a new book I'd like to be sure this is covered, just don't know what it is I'm looking for to be covered
Thanks in advance!
|
|
|
|
|
That's the $_GET-function.
Have a look here, it's pretty simple: PHP $_GET Function[^]
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Exactly what I was looking for, thank you!
|
|
|
|
|
Welcome.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Which should be the best PHP Webmail system to access my mail remotely to meet such requirements?
- Outlook Synchronization
- HTML email composing
- IMAP support, including IMAP over SSL
- Live Spell Check
Roundcube Webmail, AfterLogic WebMail, AtMail, SquirrelMail, Which one should be the exact one I am looking for?
Thx
Wallace
|
|
|
|
|
SquirrelMail will out of the box not fit the spell checking nor HTML format I believe, RoundCube does everything you want. I personally don't know the other two. Except for one thing, which is Outlook synchronization. What do you mean by this (mail sync, calendar), Outlook consists out of several features.
If you are solely focusing on the mail part for Outlook then the PHP webclient is not an issue as Outlook will connect to the IMAP server itself, just like the webmail client.
|
|
|
|
|
If you are looking for a web based email client, then try roundcube. It has some pretty good features. On the other hand if you are looking for a email client application that runs on the desktop, try Mozilla Thunderbird. It will connect to any mail client which supports IMAP and POP3. Also it is free.
|
|
|
|
|
Hi,
I need to pass csv file data using special multiple part form post to client system -
The example they gave is -
POST /interface/list_upload_data.php HTTP/1.1
Host: response.pure360.com
User-Agent: www.xyz.com upload process
Accept: text/plain
Accept-Language: en
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1
Keep-Alive: 3600
Connection: keep-alive
Referer: http:
Content-Type: multipart/form-data; boundary=---------------------------
25578952812662351891242608872
Content-Length: 516
-----------------------------25578952812662351891242608872
Content-Disposition: form-data; name="profileName";
myProfile
-----------------------------25578952812662351891242608872
Content-Disposition: form-data; name="123456789"; filename="listData.csv"
Content-Type: text/plain
john.smith@email.com,John Smith,07798564352,Brighton
sarah.jones@email.com,Sarah Jones,0779646352,London
bob.samuel@email.com,Bob Samuel,0775354542,Cardiff
-----------------------------25578952812662351891242608872--
I can see few others had problem implementing this at this site - http://forums.asp.net/p/1449713/3305985.aspx[^]
Any ideas how can i achieve above task using php ?
Thanks
|
|
|
|
|
--- This looks alot like how an email is formated.
Content-Type: multipart/form-data; boundary=---------------------------25578952812662351891242608872
-- You will have to be read to detremine how the document is seperated and ends.
boundary= is the key
---------------------------25578952812662351891242608872 is the value.
-- Each record boundary value may have a random value or is hard coded, reguardless you will need to read it as it will seperate the documents various sections.
Content-Disposition: form-data; name="123456789"; filename="listData.csv"
Content-Type: text/plain
-- This looks like the header to the data.
john.smith@email.com,John Smith,07798564352,Brightonsarah.jones@email.com,Sarah Jones,0779646352,Londonbob.samuel@email.com,Bob Samuel,0775354542,Cardiff
-- and of course this is the data. As a csv file goes it is missing the first line which the column names but you can work around that.
-- I would save the entire post as a text file and then open that with the file function which will return an array.
-- You can then step through the file looking for the Content-Type: text/plain and then move to the next row as this is where the content data starts.
-- Then use the explode function to make a array of the individual lines of data...
john.smith@email.com,John Smith,07798564352,Brightonsarah.jones@email.com,Sarah
...becomes...
array('john.smith@email.com','John Smith','07798564352','Brightonsarah.jones@email.com','Sarah')
for here you can do whatever you need with the data.
Others may have a better approach but this will work.
Chris J
|
|
|
|
|
I have written a python module to convert CGM (Computer Graphics Metafile) to PDF files. It's limited to one page, A3 sizes only. Does anyone have a need for this program? I can post the code here if anyone is interested. python code here with a brief explanation
I don't know how to do multiple pages, so please tell me how to do this or better yet, download the source and do it yourself.
The CGM format is old, clumsy to deal with, etc. I wrote this to get our decades old image data up to a usable format.
|
|
|
|
|
Ok I've been searching for the last 3 - 4 hours and have come up with nothing that works. This should be simple but I guess in PHP it's not. All I want to do is run a query and put the results into an array. I've tried numerious things and nothing seems to want to work. my last attempt was using this:
$table = array();
if (mysql_num_rows($result) > 0) {
$i = 0;
while($table[$i] = mysql_fetch_assoc($result))
$i++;
}
$results holds the original results of the query. I've tried using $results with a loop to do what I want and that's not working so figured an array would be simple enough. Guess not...
Table results are pretty simple too, one string and two integers: name(string), bdayMonth(int), bdayDay(int): so I'm trying to get something similar to:
John Smith,12,8
Jane Doe,11,22
modified on Monday, December 20, 2010 2:25 PM
|
|
|
|
|
Hi,
I avoid multi-dimensional arrays most of the time, they often aren't worth the trouble. In this case, I opt for columnar arrays, it would look like this (not tested!):
$name = array();
$month = array();
$year = array();
for ($i=0; ; $i++) {
$row=mysql_fetch_assoc($result));
if (!$row) break; <<<<<<<<< ADDED
$name[$i]=$row["name"];
$month[$i]=$row["month"];
...
}
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Monday, December 20, 2010 2:44 PM
|
|
|
|
|
Ok I'll mess with that for a bit, see if I can get it to "work"... thanks so far
|
|
|
|
|
Ok so I was making changes and having no luck, so I was going back through everything I had that I hadn't deleted and have come across something I can't figure out... sorry for the length but I think you need to see the section:
if($dayofweek == $currentDayDay) {
if($currentDay > $lastdayofmonth) {
echo "<td width=100></td>";
$currentDayDay = $currentDayDay + 1;
$currentDay = $currentDay + 1;
}
else {
echo "<td width=100>$currentDay";
echo "<br />";
echo "Testing with $currentDay";
while($row = mysql_fetch_array($result)){
echo "Yet another test";
echo "<br />";
echo $row['bdayDay'];
if($row['bdayDay'] == $currentDay) {
echo $row['name']. " - ". $row['bdayDay'];
echo "<br />";
}
}
echo "</td>";
$currentDayDay = $currentDayDay + 1;
$currentDay = $currentDay + 1;
}
}
Ok the "Yet another test" only shows up one time, however the "Testing with $currentDay" shows up every time. If I could get it to (for a lack of better words) show up every time it would solve the array problem. Any ideas?
--- NOTE ---
When I say shows up one time I mean it loops through only the first time it gets to it (displays two lines, which is "correct")
modified on Monday, December 20, 2010 3:42 PM
|
|
|
|
|
we're moving backwards now?
I don't know what it is your code is trying to accomplish, and I'm not sure your earlier table content is still relevant; however a call to mysql_query is very absent. Once you enumerated all results, mysql_fetch_array($result) will continue to return nothing until you issue a new $result=mysql_query("some query"); . So my best guess is you need to move an existing query call inside the outer loop (both not shown).
Suggestion: while debugging PHP isn't always easy, I tend to use logging, i.e. I insert calls to some Debug function which outputs a string in a different color (often magenta). A possible implementation could be this:
function Debug($level, $string) {
if ($level<=$this->debugLevel)
echo "<p class='debug'><font color='ff00ff'>$string</font></p>\n");
}
which outputs the string provided debugLevel is sufficiently high (the snippet sat inside a class, hence the $this thingy).
|
|
|
|
|
Still new to PHP so kinda learning as I go. That section of code is creating a calendar "table" on the page. So what I have it doing is as it creates the cell for the date looking to see if anything is "happening" on that day. Being new to web programming I don't know of a better way to do it. If I were to do this in VB or C# it wouldn't be a big deal but running into some issues (obviously) with doing this in PHP. That is why I originally asked about putting this into an Array, this way I could just look to see if that value was in the array in slot what ever and go onto the next. The actual call for the query is in another function, I just passed the variable to this function like I normally would.
$con = mysql_connect($hostname, $username, $password)
or die("Unable to connect to mySQL");
echo "Connected to mySQL";
echo "<br /><br />";
$selected = mysql_select_db("intranet",$con)
or die("Could not select intranet");
$result = mysql_query("SELECT name, bdayMonth, bdayDay FROM employee WHERE bdayMonth='$currentMonth'");
Not sure if that really helps that much, but figured I'd show what I've got.
That should as mentioned before return something along the lines of:
---------------------------------
| name | bdayMonth | bdayDay |
---------------------------------
|Jon Doe | 12 | 9 |
---------------------------------
|Jane Doe | 12 | 22 |
---------------------------------
normally I'd do a simple loop of for each row in array what ever where bdayDay equals currentDay or something along those lines... Then when you find one some sort of print statement like "array(x,0) Birthday!" or is it array[x][0]?
Enjoying this new challenge, just not the headache
|
|
|
|
|
OK. This is what I would probably do:
1. first get all the data from the database and turn it into an "associative array", i.e. an array that maps birthday dates (could be 100*month+day) to some text.
2. then create the HTML for the calendar; for each cell look in the associative array, and when an entry exists for that date, add the string to the output.
The nice thing about associative arrays is you don't need to search them with a loop, you don't need to have the data sorted in a particular order, etc. This[^] might help.
|
|
|
|
|
Thanks for the tip and link, I have some other things to do first this morning but I should get to this in the afternoon if I run into any problems I'll let you know.
|
|
|
|
|
I don't know if I'm not using the write terms but I still can't find anything on how to populate an array with code. Every example I've come across is all hard coded which is great when you want to test it out, but doesn't do much good for live deployment. Maybe I missed it in that page you mentioned so I'm going to look again, but still not having much luck here. Thinking this is going to be one of those "oh yeah" moments like when I first learned how to do multiple threads. Thanks in advance.
|
|
|
|
|
This is part of a function that returns an array with all the table names in a MySQL database:
$query="SHOW TABLES";
$Results=mysql_query($query);
if (!$Results) die("DB Error in GetTableNames ($query)".mysql_error());
$res=array();
while($row=mysql_fetch_array($Results)) $res[]=$row[0];
the result is a simple array, not an associative array! It behaves like a list as things were added one after another without using an index. Nevertheless, you can retrieve them by index.
this untested example would use an associative array:
$query="SELECT field0,field1 FROM table";
$Results=mysql_query($query);
$res=array();
while($row=mysql_fetch_array($Results)) $res[$row[0]]=$row[1];
this uses field0 as the index (even when not numeric) and field1 as the data to be stored.
If you aren't getting such information from where ever it is you learn PHP, I suggest you switch to another book or course!
|
|
|
|
|
I'm learning this as I go, so if you have any good books you can point me towards I'm all for that. Not having much luck with the web searches, plus I'm more of a book person anyways.
All of my web exp is in HTML and ASP so for this, I'd say I'm around zero. I know what I want to do, just can't do it in PHP right now but I'm working on it
Moving from ASP to PHP is going to be a chore for sure, but at least I don't have a time frame so that is good. This is for our intranet page which is towards the bottom of the list of my daily things to work on so I'm not up against a deadline or anything. Arrays are so much easier to work with in M$ land, however if this was easy then everyone would be doing it. Maybe because my background is different but I don't see where I'm trying to do anything so far our in right field that I can't even find a remotely close example online that I can work around. That or they are there and due to my lack of PHP exp I'm looking over them. Either way I know what I'm working on tomorrow, trying to get these results from the sql query into some sort of array or list, yay!
|
|
|
|
|
IMO PHP is a big step backwards if you're used to strongly types languages (C/C++/Java/C#/...).
I started my web site in PHP years ago, and I now regret it isn't ASP.NET
I have read two books when I needed to get a feeling for PHP+MySQL, years ago, however not anything particular I'd recommend.
Debugging is rather hard, I tend to insert logging statements, I already told you that.
I'm quite pleased with what is available on the web, in particular http://www.w3schools.com/php/default.asp[^], and maybe also http://www.tuxradar.com/practicalphp[^] and http://www.freewebmasterhelp.com/tutorials/phpmysql[^].
I do use Google a lot, often searching either PHP function_name, or PHP functional_keywords
|
|
|
|
|
Well I already have the site up and running with ASP, but it's being "served" off my local pc instead of the server (long story that just raises my BP). I have since been able to acquire a Linux server at work and thus the PHP need now. Yeah I got the ASP calendar working in about 5 hours total, vs the 4+ days of just trying to get this one array to work
|
|
|
|
|