Jump to content

uchiha007

Members
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

0 Neutral

About uchiha007

  • Rank
    Newbie
  1. Well is a full website I am working. Is for a friend, and asked me to do a website for her. I have been studying web design/programming for about 6 months now and I am starting to feel a little confident on my work(the only areas I know completely by heart is HTML,XHTML,CSS). I would like some criticism cuz being the amateur I am, I know I am doing mistakes and stuff that does not looks at a professional level. Go crazy with criticism, my motto for critiques is the harshier the better lol. Anyways here's the link:http://yarlexrealty.0sites.net/ Cheers and thanx =]****EDIT: BTW, I know that some pages don't validate. I am still working on them
  2. Well this has been a hairpulling situation that I am stuck in. I can manage to upload multiple images to the server, but not to the database in MySQL. What I want is to make a gallery database table so I can then call those images uploaded in a certain way. I can't rely on uploading it the serer because with the images names is hard to make them come out the way I wanted, so I figured the best would be to upload it to a db table and from there sort them by id_number,only then sill I be able to do what I want. Is just my way of thinking tho, if there's an easier way that does not require to upload it to a database then by all means please tell me =]
  3. Well so far, all the way to functions, but I was reading it side-by-side with MySQL. I skipped a bit too to MySQL Insert. will read a bit more then and see how it goes. One last question tho, if I were to upload an image through a form to be echoed in another page, will I have to upload it to the database or just a directory on the server?
  4. That is exactly what I want to do, but I don't know how to write the script. You think you could help me a little? I already did that. The info of the form is stored at the db in a table, but I want that info to be shown in a way on the main page(index.php) and right after I send the information. I get what you are saying about the id incrementing, makes a lot of sense and about the date too, since I am planning on making a search engine to scout around the db for that info.
  5. lol damn that explains why the info dissappeared later. How can I make the db display that in a loop after a refresh?
  6. Well, it's been killing for a while now. I am very new to PHP and have been able to get some of the code runnin the way I want it to, but the rest is really complicated. I am working on a website for a friend's company and I made a form so he can submit info and pictures. Now, this form comes out in a popup and then when it's done it closes and refreshes the parent page in order to output that information. The process is something like this: index.php -> form.php(popup) -> upload-script.php(data goes to db in MySQL) -> form.php closes then index.php refreshes to show information. I was able to get the process running, and the output too by using sessions, BUT I want that info to stay there, and be able to loop so that old information moves down, and the new one on top. What I want to achieve is something like, let's say, a comment box, where whatever is types on the text area outputs a certain way. Here's the script for the upload code: <html><head><script type="text/javascript"><!--function redirectbtn(){ window.close(); if (window.opener && !window.opener.closed) { window.opener.location.reload(); }}--></script></head><body><?php$mlsnum = $_POST['mlnum'];$address = $_POST['address'];$price = $_POST['price'];$street = $_POST['street'];$status = $_POST['status']; // the code to the left is how I pull the data out of the form and into the variables. $bedrooms= $_POST['beds']; // Where it says $_POST['address']; address is the name of the input on the previous form.$yb = $_POST['year_built']; // POST is PHP's way of requesting the data once the submit button is pressed.$city = $_POST['city'];$property_type = $_POST['property_type'];$host = "localhost";$username = "ds00x"; // The three variables to the left are your servers connection details if your using WAMP as standard these$password = "2uchiha"; // are correct if you didn't change them during set up.$db_name = "ds00x_main";$tbl_name = "Properties"; // finally the two variables to the left are your data base details change these if you need to connect to a different Databasemysql_connect($host, $username, $password)or die("Could Not connect.");mysql_select_db($db_name)or die("could not find or conenct to the data base."); // the two lines of code to the left connect to your server and Database.$sql = "INSERT INTO $tbl_name (MLS_Number, Address, List_Price, Street, Status, Bedrooms, Year_Built, City, Property_Type) VALUES ('$mlsnum', '$address', '$price', '$street', '$status', '$bedrooms', '$yb', '$city', '$property_type')"; //The two lines of code to the left insert all data into your DB the top line of code is your DB's column names change any if there wrong. The bottom line of code is the variable data from the form.mysql_query($sql); //this line to the left process the query above.if ($sql == true) //This if statment checks if your query was successful if so it registers the sessions on the main page. and echo's a message to your client.{echo "<p>Your message here if successful submission of house details</p>";// Change this message if successful@session_start();$_SESSION['mlnum'] = $mlsnum;$_SESSION['address'] = $address;$_SESSION['price'] = $price;$_SESSION['street'] = $street;$_SESSION['status'] = $status;$_SESSION['beds'] = $bedrooms;$_SESSION['year_built'] = $yb;$_SESSION['city'] = $city;$_SESSION['property_type'] = $property_type;}else // If there query has failed then the message below gets echoed instead and they still get redirected back to the form to try again.{echo "<p>Your message here for failure of submission of house details.</p>"; // Change this message if it failed.}?><?php $success = 0; $fail = 0; $uploaddir = 'upload/images/'; for ($i=0;$i<4;$i++) { if($_FILES['userfile']['name'][$i]) { $uploadfile = $uploaddir . basename($_FILES['userfile']['name'][$i]); $ext = strtolower(substr($uploadfile,strlen($uploadfile)-3,3)); if (preg_match("/(jpg|gif|png|bmp)/",$ext)) { if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $uploadfile)) { $success++; } else { echo "Error Uploading the file. Retry after sometime.\n"; $fail++; } } else { $fail++; } } } echo "<br> Number of files Uploaded:".$success; echo "<br> Number of files Failed:".$fail;?><button type="button" onclick="redirectbtn()">Click Here to Continue</button></body></html> And here is the one for the output: <?php session_start(); $mlsnum = $_SESSION['mlnum']; $address = $_SESSION['address']; $price = $_SESSION['price']; $street = $_SESSION['street']; $status = $_SESSION['status']; $beds = $_SESSION['beds']; $yb = $_SESSION['year_built']; $city = $_SESSION['city']; $prop = $_SESSION['property_type']; //The code above uses sessions a session is PHP's way of displaying information regardless of which page a user is on. //Log in scripts use them that is how once logged in your username can be echoed throughout the site. ?><html> <head> <title>Database submission scripts</title> </head> <body> <h4>Your site and DB connection script test page.</h4> <form method="POST" action="guyscode.php"> <!--Action="" makes the form submit data to a certain page. method="post" makes PHP submit it as a post session.--> <i>MLNUM</i><input type="text" name="mlnum" /><br /> <i>Address</i><input type="text" name="address" /><br /> <i>Price</i><input type="text" name="price" /><br /> <i>Street</i><input type="text" name="street" /><br /> <i>Status</i><input type="text" name="status" /><br /> <i>Beds</i><input type="text" name="beds" /><br /> <i>Year</i><select name="year_built"> <option>1989</option> <option>1988</option> <option>1987</option> <option>1986</option> <option>1985</option> <option>1984</option> </select><br /> <i>City</i><input type="text" name="city" /><br /> <i>Type</i><input type="text" name="property_type" /><br /> <input type="submit" /> </form> <p>__________________________________________________</p> <?php echo " $mlsnum $address $price $street $status $beds $yb $city $prop "; // The variables above are what is used to echo out the content a user entered into the form. //echo is PHP's way of displaying information to the user. ?> <p>__________________________________________________</p> <p> Hi this is your code you asked for I have also included a log in script for users and register script if you so need them. Please note these scripts contain no security. </p> </body></html> As you can see I am using sessions so the info migrates, but I am not sure if they are the right ones to use or not. All that info from the sessions is what I want to be posted in a loop. It works to migrate the info, but unfortunately it dissappears when I close the browser and open the page again. Any suggestions?
×
×
  • Create New...