473,836 Members | 1,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

writing a session value to file

Hello,

windows xp, apache, php and my sql and dreamweaver mx

I have the code below. And it does'nt work! Basically the code below
is the workings behind the scene that inserts a record to a table and it
gets most of it's value from a form. There's alot more to the code such
as the bindings to text boxes etc but I don't think I need to show you
that, just the basics.

Most of the values come from text box bindings but one of them is a
hidden value $custid Basically a user has logged in prior to the insert
page and then I set a session with their userid. When they then want to
insert a record I don't insert the userid but the customer id ($custid)
and I have a bit of code that supposedly grabs the custid from a
customers table doing a join on the userid.

The insert code below works but it writes back nothing to the custid
field in the table. The code below is a combination of dreamweaver mx
generated code and my hand code.

Any idea?

Thanks,

td

<?
session_start() ;
if ($_SESSION[loggedin] != "yes") {
header("Locatio n: http://127.0.0.1/custlogin.php") ;
exit; }
require_once('C onnections/local.php');
// this bit gets the custid from the cutomers table and assigns it to
the variable $thecustid
$thecustid = "SELECT custid FROM customers WHERE userid='" .
$_SESSION['MM_Username'] . "'";
// dreamweaver created all this
function GetSQLValueStri ng($theValue, $theType, $theDefinedValu e = "",
$theNotDefinedV alue = "")
{
$theValue = (!get_magic_quo tes_gpc()) ? addslashes($the Value) :
$theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValu e) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theV alue) . "'"
: "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValu e :
$theNotDefinedV alue;
break;
}
return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_ SERVER['QUERY_STRING']);
}

// below is all the insert code, note how I have $custid but nothing is
written back even though I have set it above
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmaddsw") ) {
$insertSQL = sprintf("INSERT INTO software (title, shortdesc, `desc`,
version, minreqs, wareid, catid, hpage, dllink, dlsize, triallength,
price, keywords, submitdate, submittime, liveyn, custid) VALUES (%s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, current_date(),
current_time, 'N', '$thecustid')",
GetSQLValueStri ng($_POST['title'], "text"),
GetSQLValueStri ng($_POST['shortdesc'], "text"),
GetSQLValueStri ng($_POST['desc'], "text"),
GetSQLValueStri ng($_POST['version'], "text"),
GetSQLValueStri ng($_POST['minreqs'], "text"),
GetSQLValueStri ng($_POST['wareid'], "int"),
GetSQLValueStri ng($_POST['catid'], "int"),
GetSQLValueStri ng($_POST['hpage'], "text"),
GetSQLValueStri ng($_POST['dllink'], "text"),
GetSQLValueStri ng($_POST['dlsize'], "text"),
GetSQLValueStri ng($_POST['triallength'], "text"),
GetSQLValueStri ng($_POST['price'], "double"),
GetSQLValueStri ng($_POST['keywords'], "text"));

mysql_select_db ($database_loca l, $local);
$Result1 = mysql_query($in sertSQL, $local) or die(mysql_error ());
}
Jul 17 '05 #1
0 1258

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
7137
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate a user from information you got from the session. Each secure app on a site must challenge the user for name and password, each and every time the user accesses it (not just once and then store it in the session). If a secure app is multi-page,...
1
4377
by: mudge | last post by:
I'm running PHP Version 4.3.10. I'm trying to make it so that when a person logs in using a user name and password that their session is valid and continues for a few months so they don't have to log in each time they come to the site. In a .htaccess file I set session.cookie_lifetime to 20736000 seconds and I set session.gc_maxlifetime to 20736000 It works for about 30 minutes. A user can login and then close their browser and then...
0
1984
by: Pat Blair | last post by:
Sorry to anyone who read this post, but in case it's useful to anyone: Further experiments reveal that while a tuple comes back if you read a multi-line string, you set the value using a list (not a tuple). That's sensible and I don't know why this didn't occur to me before I posted. Thanks -----Original Message----- From: Pat Blair
20
3565
by: Brian Burgess | last post by:
Hi all, Anyone know if this is possible? If so, on which page would the cookie be? .. On the page calling a function defined in the include file? thanks in advance.. -BB
3
2926
by: Geoff Winsor | last post by:
Hi, I am experiencing a problem with recalling a session variable which stores whether a person is logged in to a "members only" section of a website. This area of the site has been working flawlessly for a couple of years under Windows 2000 server but now is very inconsistent following a recent upgrade to Windows server 2003. Following a login, the login info is passed to this asp page that checks an Access database for the user name and...
2
2297
by: John Mullin | last post by:
We are having a problem which appears similar to a previous posting: http://groups.google.com/groups?hl=en&lr=&frame=right&th=d97f552e10f8c94c&seekm=OZw33z9EDHA.2312%40TK2MSFTNGP10.phx.gbl#link1 In the current release of our system, we decided to "wrap" the ASP.NET Session and Application objects to improve code clarity and accuracy. For example, instead of: Session = new SomeListClass;
4
2185
by: HNguyen | last post by:
Hi, I have a Web application in ASP.NET. My Application allows the users upload files into the server after checking their user names and passwords. For each transaction, the Web program will write the information about user name, filename upload, filesize, date and time of uploading into the log file. (The name of the log file is constructed by Current Year and Current Month in my program). Is there any problems with writing into the...
11
3015
by: Vishal | last post by:
Hello, can anybody tell me how I can extend the session expiry time? Is it done via code or via IIS? Sorry I am new and dont know about this.
2
14690
by: lookee | last post by:
Hello all, I have simple PHP application that on one page strarts session and write some information to it. On another page program tryes to fetch information from a third page using cURL. On that third page program needs to retrive information that were written to the session and use them. Problem is that when I call the third page and call session_start() it starts a new session where there are no infromation I need. Code below. ...
0
1360
by: hshah | last post by:
Hello All, I have created a .aspx page with 7 text boxes and a save button. On click event following code is fired. It save the property information to sql server and also generate a unique Id for that porperty and fatch that id and show it on that screen. I have created a .cs file for TrustConnectionString as below. Can someone please help me or guide me, is this a good practice to write code? If not can you please help me how to...
0
9677
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10862
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10560
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10262
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6986
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5838
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4468
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.