Dreamweaver Code

This is a discussion on "Dreamweaver Code" within the PHP Forum section. This forum, and the thread "Dreamweaver Code are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Closed Thread
 
LinkBack (1) Thread Tools
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old Jan 3rd, 2004, 03:13
Reputable Member
Join Date: Aug 2003
Location: Singapore
Posts: 321
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gwx03
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..

  #2 (permalink)  
Old Jan 3rd, 2004, 03:20
Reputable Member
Join Date: Aug 2003
Location: Singapore
Posts: 321
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gwx03
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.
  #3 (permalink)  
Old Jan 4th, 2004, 15:39
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
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?
  #4 (permalink)  
Old Jan 5th, 2004, 07:28
Reputable Member
Join Date: Aug 2003
Location: Singapore
Posts: 321
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gwx03
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...
  #5 (permalink)  
Old Apr 3rd, 2004, 09:44
New Member
Join Date: Apr 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Closed Thread

Tags
code, dreamweaver

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
code behind code doesnt work skat ASP.NET Forum 4 Feb 18th, 2008 10:05
adobe dreamweaver Vs. Macromedia dreamweaver jahphill Scripts and Online Services 21 Nov 2nd, 2007 03:19
FrontPage generated Form code to Dreamweaver femyram Web Page Design 2 Oct 11th, 2007 07:01
live search code and styleswitcher code hebel JavaScript Forum 0 May 12th, 2007 06:16
Can somebody give me the code to hide the source code? renren JavaScript Forum 7 Mar 7th, 2006 12:27


All times are GMT. The time now is 01:58.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43