Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

75 users online



if -else help

if -else help

Currently viewing this thread: 1 (0 members and 1 guests)


mbennett

mbennett

Neverside Newbie
Status: Offline!

if -else help

Well I am not the best PHP programmer in the world and never will be lol. But I have been developing on my server (cPanel, apache, php,mysql) and have done some work for someone and the site is going on another server. and for some reason when i call the file dynamically like http://sitename.com/admin/edit_job.php?id=6&edit=show it will no longer work. The site worked fine on my server and now its moved to this new server it wont parse right. It just shows the javascript drop down. It would used to go to the edit page. http://dimonandbacorn.com/test/edit_job.php is what I am working on now. And I know the main issue somewhere is the $PHP_SELF and the problem lays with

Code:

if ($edit == "show") {

is there a new way of doing this?

the code is below minus the javascript. i have that in the page but not included below.

Like I said im not the best and my stuff does what it needs to do (on my server....lol)

Code:

<?

require "../config.inc";

# edit - show
if ($edit == "show") {

$db = mysql_connect("$dbhost", "$dbuser", "$dbpassword");
mysql_select_db("$dbname",$db);

$result = mysql_query("SELECT * FROM jobs WHERE id = '$id'",$db);
$jobz = mysql_fetch_array($result);

do {
$id = ($jobz["id"]);
$job_title = ($jobz["job_title"]);
$description = ($jobz["description"]);
$active = ($jobz["active"]);

echo "
<form method=\"post\" action=\"?id=$id&edit=done\">

<input type=\"hidden\" name=\"id\" value=\"$id\">

<b>Job Title</b><br>
<INPUT TYPE=\"TEXT\" NAME=\"job_title\" size=\"35\" maxlength=\"70\" class=\"text-field\" value=\"$job_title\"><p>

<b>Job Description</b><br>
<TEXTAREA NAME=\"description\" ROWS=\"5\" COLS=\"65\" class=\"text-field2\">$description</TEXTAREA><p>

<b>Set Listing Active</b><br>";

if ($active == "0") {
echo "<select NAME=\"active\">
<OPTION VALUE=\"0\" NAME=\"active\" SELECTED>No</option>
<OPTION VALUE=\"1\" NAME=\"acitve\">Yes</option>
</select>";
} else {
echo "<select NAME=\"active\">
<OPTION VALUE=\"0\" NAME=\"active\">No</option>
<OPTION VALUE=\"1\" NAME=\"acitve\" SELECTED>Yes</option>
</select>";
}

echo "<p>
<input type=\"Submit\" name=\"submit\" value=\"Enter Information\" style=\"border:1px solid #C80708; background-color: #cccccc; color: #000000; font-weight: bold\">";

} while ($jobz = mysql_fetch_array($result));

echo "</form>";

#edit - done
} elseif ($edit == "done") {

$db = mysql_connect("$dbhost", "$dbuser", "$dbpassword");
mysql_select_db("$dbname",$db);

$sql = "UPDATE jobs SET id='$id',job_title='$job_title',description='$description',active='$active' WHERE id=$id";
//replace news with your table name above
$result = mysql_query($sql);
echo "<center><span class=\"main\">Thank you! Information updated.<p>
<a href=\"$PHP_SELF\">Edit Another Job</a> | 
<a href=\"index.php\">» Back to Control Panel</a></span></center>";

#edit - else
} else {

$db = mysql_connect("$dbhost", "$dbuser", "$dbpassword");
mysql_select_db("$dbname",$db);

$result = mysql_query("SELECT * FROM jobs ORDER BY id",$db);
$jobz = mysql_fetch_array($result);

echo "<form name=form2>
<select onChange=\"MM_jumpMenu('parent',this,0)\" name=menu2>
<option value=\"\">Make a Selection</option>";

do {
$id = ($jobz["id"]);
$job_title = ($jobz["job_title"]);

echo "<option value=\"?id=$id&edit=show\">$id - $job_title</option>";

} while ($jobz = mysql_fetch_array($result));

echo "</select></form>";

}

?>

theTrinity

theTrinity

David
Status: Offline!

Instead of $edit, try putting $_GET['edit']. Chances are, register_globals are off.

Anything you have as a query string... ?id=1&edit=blah

change it to $_GET['id'] and $_GET['edit'].

Last edited by theTrinity, April 23rd, 2005 04:29 AM (Edited 1 times)

mbennett

mbennett

Neverside Newbie
Status: Offline!

thanks for the quick reply but where exactly might i add that? to make it wok?

I checked and register globals is off.

thanks again

edit.........

like this?

Code:

if ($edit == "show") {

what do i change that to, to make it work?

Last edited by mbennett, April 23rd, 2005 04:41 AM (Edited 1 times)

iFex

iFex

Neverside Newbie
Status: Offline!

elaborating on the above, i'd just change #edit - show to a get statement:

Code:

$edit = $_GET['edit'];

this way saying if( $edit == "show" ) will still funcion -- saves from typing $_GET['edit'] everytime you want to use it.

mbennett

mbennett

Neverside Newbie
Status: Offline!
Originally posted by iFex:

elaborating on the above, i'd just change #edit - show to a get statement:

Code:

$edit = $_GET['edit'];

this way saying if( $edit == "show" ) will still funcion -- saves from typing $_GET['edit'] everytime you want to use it.

sweet thanks that worked good.

mbennett

mbennett

Neverside Newbie
Status: Offline!

ok i have never worked with register globals off. but on another page when someone contacted through a form it would send mail. But it doesnt send. Could someone please help there too. BTW you guys rock. THis is what I used.

http://dimonandbacorn.com/phpinfo.php

Code:

/* recipients */
$to = "name@email.com";

/* subject */
$subject = "Free Estimate Request";

/* message */
$message = "
<html><head><style>
a:link {color : #9d0040; font-family: Arial; text-decoration: none; font-size: 12px;}
a:visited {color : #9d0040; font-family: Arial; text-decoration: none; font-size: 12px;}
a:active {text-decoration: none; font-family: Arial; font-size: 12px;}
a:hover {text-decoration: underline; color: #003d7c; font-family: Arial; font-size: 12px;}

.main {
font-size : 12px;
color : #000000;
font-family: Arial;
}

</style></head>

<span class=\"main\">There has been a request for a free estimate from $name.<br>
Log into the control panel at <a href='http://.........................../estimates.php'>http://............................................/estimates.php</a>.<p></span>

</html>";

/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "From: $name <$email>\r\n";

/* and now mail it */
mail($to, $subject, $message, $headers);

Last edited by mbennett, April 23rd, 2005 05:16 AM (Edited 2 times)

Waldir

Waldir

God's Son
Status: Offline!

hehe, its the same thing as before but before you went over the $_GET['var']. now its the post, everything that you post on a form has t be $_POST['var'] so if you submited the message with the form u have to do something like $message = $_POST['message']; same as before. Smile

___________________

"The secret to creativity is knowing how to hide your sources." -- Albert Einstein

mbennett

mbennett

Neverside Newbie
Status: Offline!

ok ill try that but even with register globals off it should still send fine once i get the variables in there from the post?

Waldir

Waldir

God's Son
Status: Offline!

it should

___________________

"The secret to creativity is knowing how to hide your sources." -- Albert Einstein

theTrinity

theTrinity

David
Status: Offline!

http://www.php.net/manual/en/language.variables.predefined.php

That might help.

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0099 seconds.