tomfmason Posted August 7, 2006 Share Posted August 7, 2006 I am having an issue with a form. I have tested everything that I can think of. I am sure that it is a rather simple issue. Ok this form posts to it's self and then is supposed to include a function from another file.Here is the form.[code]<?phpinclude("db.php");include("functions.php"); if (isset($submit)) { if (!$domain) { $message = "domain"; exit(); } $domain = $_POST['domain']; $domain = stripslashes($domain); $username = "test"; $user_id = "65"; $test = addDomain(); if ($test == "false") { $message = "add"; }else{ $message = "sucess"; } }?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Add Domain</title></head><body><?phpif ($message == "domain") { echo "You did not enter a domain";}if ($message == "add") { echo "unable to add the new domain";}if ($message == "success") { echo "The domain was added sucessfuly";}?><form action="domains.php" method="post"><p>Add a Domain</p> www.<input type="text" name="domain"><input type="submit" name="submit" value="Add Domain"></form></body></html>[/code]and here is the addDomain function[code=php:0]function addDomain() { function updatedb() { global $domain; global $user_id; global $ip; $sql = mysql_query("INSERT INTO `domains` (`user_id`, `domain`, `date_added`) VALUES ('$user_id', '$domain', now())"); if (!$sql) { $result = "false"; } return $result; } function createDir() { global $domain; global $username; $newDomain = mkdir("C:/home/$username/$domain"); if (!$newDomain) { $result = "false"; }else{ $public = mkdir("C:/home/$username/$domain/public"); $private = mkdir("C:/home/$username/$domain/private"); $sub = mkdir("C:/home/$username/$domain/sub_domains"); if ((!$public) || (!$private) || (!$sub)) { $result = "false"; } } return $result; } $updateDb = updateDb(); $createDir = createDir(); if ($updateDb || $createDir == "false") { $result = "false"; } return $result;}[/code]I tested calling the addDomain() at the end of the functions.php and it works just fine. It creates the needed directorys. Any suggestions would be great.Thanks,Tom Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 7, 2006 Author Share Posted August 7, 2006 the damn script got knocked out of wack again. I swear my coding is cleaner then this. It may not be 100% correct but at least it is clean..lol Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 7, 2006 Share Posted August 7, 2006 if this a case of testing on a different machine than the live serve you should check to see if register_globals is on or off (it should be off!) and i suspect the testing server has it turned on.You should useif (isset($_POST['submit']))instead of justif ($submit)OR you can define the short name vars before you process any of the post/get data$submit = $_POST['submit'];and so on....ALSO it is probably better to pass all the data to the function implicitly instead of using global within the function - just gets you used to doing things in a 'strict' manner. but it aint that important here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.