iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Closed Thread
 
LinkBack (1) Thread Tools
Old January 2nd, 2004, 11:13 PM   1 links from elsewhere to this Post. Click to view. #1
Reputable Member
 

Join Date: Aug 2003
Location: Singapore
Posts: 318
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 gwx03 will become famous soon enough
Dreamweaver Code

As you know, dreamweaver does a lot of junk with PHP code... I did some housekeeping and here's what I got..


<?php require_once('Connections/mydb.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";


return $theValue;
}

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

if ((isset($_POST["MM_insert])) && ($_POST["MM_insert] == "contact")) {
$insertSQL = sprintf("INSERT INTO contact (name, email, title, message) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['message'], "text"));

mysql_select_db($database_mydb, $mydb);
$Result1 = mysql_query($insertSQL, $mydb) or die(mysql_error());

$insertGoTo = "contact_success.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo = "contact_success.php";
}

}
?>

The problem is that it would work, but there is no redirect to contact_success.php. Actually, what I deleted was just a switch, which contained like 10 lines. That switch does nothing but determine if the text input is string, integer, or anything, and as you see, I put the one for the integer.

I was not the one who wrote this messy code so I do not know what is actually happening. To me, it is just one whole lump of messed-up, very very fragily inter-linked code.

Can someone please help reverse engineer this, and tell me what I should do to do the redirect to "contact_success.php". I don't know what the variable $insertGoTo does, it all seems sooo confusing..

<form action="<?php echo $editFormAction; ?>" method="POST" name="contact" id="contact">


Name :
<input name="name" type="text" id="name" size="30" maxlength="30">
</p>



Email :
<input name="email" type="text" id="email" size="30" maxlength="30">
</p>


Title :
<input name="title" type="text" id="title" size="50" maxlength="50">
</p>


Message :</p>



<textarea name="message" cols="70" rows="8" id="message"></textarea>
</p>



<input name="clearval" type="reset" id="clearval" value="Clear Values">
<input name="Send" type="submit" id="Send" value="Send">
</p>
<input type="hidden" name="MM_insert" value="contact">
</form>

That's the form code above. But its actually nothing..
gwx03 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old January 2nd, 2004, 11:20 PM   #2
Reputable Member
 

Join Date: Aug 2003
Location: Singapore
Posts: 318
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 gwx03 will become famous soon enough
And yes, can anyone explain to me what this code does..
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

This is as far as I can tell..

1st line : $editFormAction (variable) is given a value of the $_SERVER(variable) and we see some stuff enclosed in [].. whats that!!

2nd and 3rd line :
if isset ( don't know whats isset.. ) and the stuff in the further enclosed () I do not understand!.. then variable $editFormAction is set to '?' + htmlentities(some alien code)

Ahh.. The 3rd Line I don't get it at all.

PLEASE! Someone explain! Arghh.
gwx03 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old January 4th, 2004, 11:39 AM   #3
WebForumz Admin Badge
 

Join Date: Jul 2003
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 109 Webforumz Staff is on a distinguished road
Firstly on your last post. The first line uses a server variable. A server variable is information about the server environment. For example, the server name, the IP of the visiting user, your browser type, etc. In this case _SERVER["PHP_SELF] is the name of the page that has been called.

Here is PHPINFO - A built in command in PHP that will display all the server variables and environment information. http://www.digital-end.com/phpinfo.php
You can do this on your own server using the phpinfo() function.

Now as for isset, it does exactly what it says on the tin! It checks if a variable exists. If it does then the contents of the if statement are executed. If not, then...not!

By now you can probably guess what $_SERVER['QUERY_STRING'] is? It's the query strings (the variables passed via an URL. Eg: mypage.php?page=contact

$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

This is actually quite simple... this creates (or changes) a variable called editFormAction to be a question mark and whatever query string has been passed. htmlentities simply converts all characters to HTML entities, so that spaces become %20 and so on.
The idea here, I presume, is that a form is sent to the relevant place. Basically, this script can display a form and then send it to any number of places depending on what query string you have passed. So in order to go to contact_success.php just put that as the query string. It appears that the querystring should be $theValue, but this script IS very confusing, badly written and has no comments at all! There should at least be a short description of what the script does as well as comments to which variables do what, etc.

I can't determine what insertgoto does?
Webforumz Staff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old January 5th, 2004, 03:28 AM   #4
Reputable Member
 

Join Date: Aug 2003
Location: Singapore
Posts: 318
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 gwx03 will become famous soon enough
I just got the error :
Parse error: parse error in /home/cvgwx/public_html/contact.php on line 15

Line 15 happened to be $editFormAction.=$_SERVER['PHP_SELF'];

I guessed it was pretty much unrelated, because I don't see $theValue variable anywhere except the function GetSQLValueString...

Is there a way to get around this or could you tell me how I could go about doing a redirect with PHP once the submit button is clicked..? If you could tell me how to do so, I would rather use that than relying on Dreamweaver...
gwx03 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old April 3rd, 2004, 04:44 AM   #5
New Member
 

Join Date: Apr 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 iamzoli is on a distinguished road
this code will never work because the variable $insertgoto whatever what is asignet the value string text contact_success.php so maybe a part of the code is missing.I supose something like this if(condition)
{
$insertgoto="contact_success.php";
}
else
{
$insertgoto="contact_failed.php";
}

and then must be a function that takes the variabile $insertgoto
function something($insertgoto)
{
redirectto($insertgoto);
}
Please tell us what exactly you are try'ing to do and we will try to find another way to do this.
iamzoli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Bookmarks

Tags
code , dreamweaver


LinkBacks (?)
LinkBack to this Thread: http://webforumz.com/php/14-dreamweaver-code.htm
Posted By For Type Date
dreamweaver php code This thread Refback September 7th, 2006 02:43 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
code behind code doesnt work skat .NET 4 February 18th, 2008 06:05 AM
adobe dreamweaver Vs. Macromedia dreamweaver jahphill Forums, Blogging and Content Management 21 November 2nd, 2007 12:19 AM
FrontPage generated Form code to Dreamweaver femyram HTML, XHTML and CSS 2 October 11th, 2007 03:01 AM
live search code and styleswitcher code hebel JavaScript 0 May 12th, 2007 02:16 AM
Can somebody give me the code to hide the source code? renren JavaScript 7 March 7th, 2006 08:27 AM


Search Engine Optimization by vBSEO 3.2.0 RC8