Jump to content
xisto Community

HmmZ

Members
  • Content Count

    365
  • Joined

  • Last visited

Posts posted by HmmZ


  1. There are many ways to achieve such urls, i personally love them but havent completely figured out the much tougher function based php

     

    I will show you a function i use for News, the authorization that is..:

    Function AuthAddNews() { Global $user,$uid, $admin, $aid, $db;if((!isset($admin)) || (!isset($user))){  Header("Location: index.php"); die();}$db->"SELECT * FROM ".$prefix."_permission where userid="".$uid." OR adminid="".$aid."";$result = query();$permission = mysql_fetch_rows($result);if($permission[p_admin]=!1){ if($permission[p_user]=!1){ $permission = false; $id = "anonymous"; }} else { If(isset($admin)){ $id = $aid; } if(isset($user)){ $id = $uid; } else { die(); } $permission = true;}Header("Location: index.php?act=news&permission=".$permission."&id=".$id."");}

    It's quite simple, first on the frontpage i had a link called News and the link was:

    index.php?act=news

    you just write it.

    this should open the news() function (wich should obviously have been written)

     

    Once in the news function you write your code (for example "view_news","add_news","edit_news") etcetera..

     

    those will each get their link or redirect to their function, easily done by once you want it to get kicked in, you write:

    view_news();
    and it will open/include the view_news function, when you do it that way, your url will change:

    index.php?act=view_news

    in view_news you can do the same, but, if you have permissions set (guests cant see news for example) you dont have to do it with opening the function within a function, you just redirect it with the necessary (or unnecessary) tools:

    index.php?act=view_news&permission=".$permission."
    wich, if its a guest who cant view, will change the url once in the page (and with necessary text to show the visitor it may not see it):

    index.php?act=view_news&permission=false

    in the example i used, the permission is checked (wich will be used in the next function) together with the user or admin id (wich will also be needed in the next function), wich gives, for example if its user number 1100:

    index.php?act=news&permission=true&id=1100

    in your next function you can write down the code for a false permission and a true permission.

     

    Now, that's not all,

    at the end of your page, you need to add the following to get for example the act=news

    :

    //first we get the act, wich you can make anything you want!switch($_REQUEST[act]){//next we need to set a default, wich could be the "front_page" function default: front_page(); break;//in our example we only make 1 switch..to the news...wich has multiple switches...//so there are actually several switches, but not all have to be made here, since//they are within the function, these codes are purely for the thing AFTER act=//for example...act=news ... the rest behind it is WITHIN the function case: news(); break;}

    I hope this made a little sense..

    its alot of code and dont want to go through it again >.>

     

    just hoping it helps a bit, we all start from the beginning, im a tiny bit further wich gives me the privilige to be able to help others..right? :)


  2. People reply with useless replys really...

     

    But what you're asking for is not an easy function, it will need to use mysql databases aswell....

    guess ill give it a go ..

     

    First: make a mysql table

    CREATE TABLE images (img_id int(9) NOT NULL auto_increment,img_file varchar(13) NOT NULL default '',img_type enum('JPG','PNG') NOT NULL default 'JPG',img_height int(6) NOT NULL default '0',img_width int(6) NOT NULL default '0',img_bytes int(9) NOT NULL default '0',img_title text NOT NULL,img_descr text NOT NULL,img_alt text NOT NULL,PRIMARY KEY (img_id)) TYPE=MyISAM;
    The table is needed to store the images, converted images and to insert,update and retrieve image info

     

    Next:

    //Define dirs$base_img_dir = "./img/";$img_conv_dir = "./bin/";//Image table$img_table = "images";//Database connection !!needs your info!!mysql_connect("host", "user", "pass");mysql_select_db("yourtable");//Generate a unique image property..id$uniq = uniqid("");// new file name$filename = $base_img_dir.$uniq;//Get image size$imginfo = getimagesize($filename);//Get image extensionfunction image_type_to_extension($imagetype,$include_dot=false){if(empty($imagetype)) return false;switch($imagetype){case IMAGETYPE_GIF: return 'gif';case IMAGETYPE_JPEG: return 'jpg';case IMAGETYPE_PNG: return 'png';case IMAGETYPE_SWF: return 'swf';case IMAGETYPE_WBMP: return 'wbmp';default: return false;}}//full image name$Dot='.';$image="$filename$Dot$imagetype";//find non jpgif(($imagetype==gif) || ($imagetype==png) || ($imagetype==swf) || ($imagetype==wbmp)){$imagetype='jpg';//Remove original and rename new to save spaceunlink($filename);$jpgimg=$filename$imagetype;//preload checkif($imagetype=!'jpg'){$imagetype='jpg;$Dot='.';$jpgimg="$filename$Dot$imagetype;}//Load image to check correct handling$img = imagecreatefromjpg($filename);imagejpg($img, $filename);imagedestroy($img);//Done...get it into your db// insert image into dbmysql_query("INSERT INTO $img_table (img_file, img_type, img_height,img_width, img_bytes, img_title, img_descr, img_alt)VALUES('$uniq', '$img_type', ".$imginfo[1].", ".$imginfo[0].",$imgbytes, '".addslashes($HTTP_POST_VARS["title"])."', '".addslashes($HTTP_POST_VARS["descr"])."','".addslashes($HTTP_POST_VARS["alt"])."');");//Last chance on failure..if($filename$Dot$imagetype=!$filename.jpg){$color="#ff0000"';$result = "Sorry, Image conversion failed";;}else {$color="#06FF00";$result = "Success! Your image was successfully converted to the .JPG extension!";}//Result screenecho "Your Image: ".$filename$Dot$imagetype."";echo "<br>";echo "has received the following result:";echo "<br>";echo "<font color=\"".$color."\">$result</font>";

    I am (of course) unsure if this qorks, but it's a step in the right way ( i think i do know a bit of PHP o.O;-_-..

     

    Hope this helps you


  3. Hmm, doesnt sound too hard o.O

    heres my go >.>

    //check if there is a user sessionif($userdate['session_logged_in']==true){$log=$userdata['session_logged_in'];$welcome="Welcome back, ";$user=$userdata['username'];}else {$welcome="Please login or register, "";$user="Guest";}//Great the userecho "".$welcome."".$user."";

    Tell me if this works..if its not ill dig into PHPbb...

  4. Have you assigned values and names to the radio button?
    and what other language are you using to fetch the radio button selection?

    i am focussed on php so this'll be in php..

    //Query page:<?php<form action=\"your_result_page.php\" method=\"post\"><input type=\"radio\" name=\"radio_name\" value=\"1\">Option 1<input type=\"radio\" name=\"radio_name\" value=\"2\">Option 2<input type=\"submit\" value=\"submit\"></form>//Result Page:print "You have chosen ".$_POST['radio_name'].".";print "<br>";print "Is this correct?";//add more..
    remember to use the same "radio_name"

    is this what you were looking for?

  5. its not that hard..anyway..end has some flaws wich may cause the outer positioning...

    REMOVE

    <TR>  <TD COLSPAN=2>  	<IMG SRC="footer.gif" WIDTH=762 HEIGHT=49 ALT=""></TD>	</TR>
    (its at the end)

    then,
    add this to the end
    </TD></TR><TR>  <TD COLSPAN=2>  	<IMG SRC="footer.gif" WIDTH=762 HEIGHT=49 ALT="">          </TD></TR></TABLE></CENTER></BODY></HTML>

    Dont know if that helps, but it atleast gets rid of the flaws

  6. Thanks for the quick and well-commented feedback guys, i love the way noone really chooses just 1 layout, but the heade rof that 1, the footer of that 1, the color scheme of the other...:unsure:Overall, i would say most people like the base of layout 3, for now, it will do and ill work further on that 1, i saw someone liked my anaimated navigation buttons, so ill work further on it, also the header will be replaced with something more suitable. And as snil suggested, ill be changing some of the source to divs, i found out with my last site that it's a great feature.Thanks again for the feedback, i really appreciated it.P.S. Rejected, thanks for bringing up the security issue, i know what you mean, i was a complete newb (still am) with function bases php, so it shows with the issue.


  7. Wich layout would best present a 'professional' webdesign company

    Layout 1:
    Uses a simple design, HTML and PHP(Not W3C validated), with self-coded news system and projects page

    Layout 2:
    More complex design, HTML only (W3C validated), uses a simple 2 color scheme

    Layout 3:
    Originally my portfolio site, HTML and PHP(Not W3C validated), selfcoded news system and very simple design concept


    Layout 4:
    Latest website, uses a new type of coding (it's full div coded with PS CS2 Slicing), with a special div scroller wich holds off that nasty "regular" scrollbar.

    Wich one? I can't choose and im tired of showing you guys new design concepts everytime, and you guys are prolly getting tired of it too...now is your chance..to get rid of me :unsure:

    P.S. I hope the poll ahrefs work... >.<

    Dammit.. preview wouldn't show me the damn poll :D

    Notice from snlildude87:
    Posts merged.


  8. Deeply sorry for the doublepost, but i want to prevent errors in that small piece of code...forgot some )'s, here the revised version :rolleyes:

    <?php$input1=$_POST['first']; $input2=$_POST['second'];$a=$input1 + $input 2;$one="0"; $two="0";if(empty($_POST['first'])){ $one="0"; } else { $one++; }if(empty($_POST['second'])){ $two="0"; } else {  $two++; }$b= $one + $two;echo "input sumup: $a, field sumup: $b";?>

    Once again, sorry for the doublepost...if only there was an edit button...

  9. Tyssen, once you're familiar with the way errors are shown with PHP, php errors are just as easy to find as with ASP.net

    moldboy, as youmay have noticed i sometimes have a hard time understanding your questions, but if i got this right and A only has numbers..:

    <input type="text" name="first"><input type="text" name="second">
    <?php$input1=$_POST['first']; $input2=$_POST['second'];$a=$input1 + $input 2;$one="0"; $two="0";if(empty($_POST['first']){ $one="0"; } else { $one++; }if(empty($_POST['second']){ $two="0"; } else {  $two++; }$b= $one + $two;echo "input sumup: $a, field sumup: $b";?>

    There probably is some kind of function that makes this alot easier, foreach won't work because you will need to create an array, wich in this case is not possible i think.

    Hope this helps a bit..

  10. be sure session_start() is the very first thing in your script<?phpsession_start();if that's done be sure there are no blanc lines before <?php(this means no html codes and no empty lines)as a confirm i see that the error occurs on line 3, meaning your session_start(); is on line 3, should be line 2hope this helps


  11. Let me try to get this straight,

     

    you are trying to have an input field where the input (assuming a category name) will have effect on the next page.

     

    where, on the next page, it displays the amount of form lines based on what categorie name it is?

     

    or is it more like (simplified) it should ADD a next line when a new category is inputted (sounds more likely..)

     

    Assuming it is option 2 (i figured it out while writing this posts, just too tired to delete the former lines..) you are making it harder then i think it should be

     

    I created a news script and projects script yesterday and this is the method i used..

     

    make_new.php

    echo "<td><input name=\"wname\" type=\"text\" id=\"cname\" value=\"Category Name\"></td>";

    insert_new.php

    $id=$_POST['cname'];$name=$_POST['wname'];$qry="INSERT INTO your_table (id,name) VALUES('$id','$name')";$result=mysql_query($qry) or die("error..");

    display_all.php

    $qry="SELECT name,id from your_table";$result=mysql_query($qry);if(mysql_num_rows($result)==0){//print something if there are no entries..}while($cats=mysql_fetch_array($result, MYSQL_ASSOC)){print "<tr><td>$cats[name]</td><td>$cats[id]</td></tr>";}

    I am of course not sure if this works the same with forum categories, but the concept is the same, it gets the array of all name/id inputs of your category table and prints a row(<TR><TD></TD></TR>) for every entry

     

    I am tired but if you understood it, while(){} is a loop that fetches all data and prints something for every entry (you could even display $cats[name] and then a <br>, making it go to the next line..)

     

    Hope this helps just a tiny bit :rolleyes:


  12. No, php and mysql are (of course) compatible with every browser..wrong variables could make differences thoughwhat kind of user variables are you using? sessions or setcookies?I am not sure, but i know that multiple setcookies can give problems with redirects (wich basically "reload") it's a bug, but was only tested in ie and netscape, maybe mozilla doesn't have this problem, IF you got multiple setcookies, i suggest you use sessions, as they should work properly (setcookies are dramatic, the only thing setcookie should be used for is "remember" login, and even that can be avoided..)

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.