• Resolved mariuse3

    (@mariuse3)


    Hello,

    i have, i thing, a big problem.

    i almost create a little page in my local host, and now i want to integrate him to wordpress in the content instead of new posts
    my code has 5 files:

    index.php (main)

    <html>
    <a href="ivesk.php">vedam</a><p>
    <a href="display.php">ziurim</a>
    
    </html>
    ivesk.php subbmitet from
    <!DOCTYPE html>
    <html>
    
    <head>
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
    <link rel="stylesheet" href="css.css"/>
    </head>
    <body>
    
    <form name="upload" method="post" enctype="multipart/form-data"  action="upload.php">
    <font>
    <div class="fonas">
    <div class="text-center"><b>Automobilio informacija</b></div>
    <td>modelis  <input class="atitraukimas" type="text" name = "modelis" value=""/></td><p>
    <td>Kategorija:   <select class="atitraukimas" type="text" name = "kategorija">
     <option value=''><center>--PASIRINK--<center></option>
     <option value='Antikvarines'>Antikvarines</option>
     <option value='Pramonines'>Pramonines</option>
     <option value='Motociklai'>Motociklai</option>
     <option value='Mustangai'>Mustangai</option>
     <option value='Paprasti'>Paprasti</option>
     <option value='Sportiniai'>Sportiniai</option>
     <option value='Sunkvezimiai'>Sunkvezimiai</option>
     <option value='kita'>[kita]</option>
    </select>
    </td><p>
    <td>marke  <input class="atitraukimas" type="text" name = "marke" value=""/></td><p>
    <td>spalva  <input class="atitraukimas" type="text" name = "spalva" value=""/></td><p>
    <td>Salonas  <input class="atitraukimas" type="text" name = "salonas" value=""/></td><p>
    <td>Variklis  <input class="atitraukimas" ="text" name = "variklis" value=""/></td><p>
    <td>aprasymas  <textarea class="atitraukimas" name = "aprasymas" cols="30" rows="5"></textarea></td><br><br><br><br><p>
    <td> <p>Nuotrauka:</td><td> <input class="atitraukimas" type="file" name="image"></td></tr><p>
    <div class="text-center"><b>asmeninė informacija</b></div>
    <td>vardas <input class="atitraukimas" type="text" name = "vardas" value=""/></td><p>
    <td>Amzius  <input class="atitraukimas" type="text" name = "amzius" value=""/></td><p>
    <td>Lytis   <select class="atitraukimas" type="text" name = "lytis">
    <option value=''>vyras</option>
    <option value='11'>moteris<option>
    </select><p>
    <td>El. pastas   <input class="atitraukimas" type="text" name = "pastas"/><p>
    <tr><td><input class="atitraukimas" name="Submit" type="submit" value="Patvirtinti"></td></tr><br>
    <a href="index.php">atgal</a>
    </div>
    </div>
    <font>
    </form>
    </body>
    </html>

    upload.php upload info to mysql

    <?php
    $con = mysql_connect("localhost","mariuse3","marius");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("rating", $con);
    
    $allowedExts = array("jpg", "jpeg", "gif", "png");
    $extension = end(explode(".", $_FILES["image"]["name"]));
    if ((($_FILES["image"]["type"] == "image/gif")
    || ($_FILES["image"]["type"] == "image/jpeg")
    || ($_FILES["image"]["type"] == "image/png")
    || ($_FILES["image"]["type"] == "image/pjpeg"))
    && in_array($extension, $allowedExts))
      {
      if ($_FILES["image"]["error"] > 0)
        {
        echo "Return Code: " . $_FILES["image"]["error"] . "<br>";
        }
      else
        {
        echo "Upload: " . $_FILES["image"]["name"] . "<br>";
        echo "Type: " . $_FILES["image"]["type"] . "<br>";
        echo "Size: " . ($_FILES["image"]["size"] / 1024) . " kB<br>";
        echo "Temp file: " . $_FILES["image"]["tmp_name"] . "<br>";
    
        if (file_exists("upload/" . $_FILES["image"]["name"]))
          {
          echo $_FILES["image"]["name"] . " already exists. ";
          }
        else
          {
          move_uploaded_file($_FILES["image"]["tmp_name"],
          "upload/" . $_FILES["image"]["name"]);
          echo "Stored in: " . "upload/" . $_FILES["image"]["name"];
          }
        }
      }
    else
      {
      echo "Invalid file";
      }
    
         $tmpName  = "upload/" . $_FILES["image"]["name"];
    $sql= "INSERT INTO bandau (id,modelis, kategorija, marke,image)
          VALUES ('', '$_POST[modelis]','$_POST[kategorija]','$_POST[marke]','$tmpName')";
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    
    echo "1 record added";
    
    mysql_close($con);
    
    ?>
    
    <a href="index.php">i pagrindini</a>

    display.php show info

    <?php
    $con = mysql_connect("localhost","mariuse3","marius");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("rating", $con);
    
    $result = mysql_query("SELECT * FROM bandau
    WHERE   ID = (SELECT MAX(ID)  FROM bandau)");
    
    while($row = mysql_fetch_array($result))
      {
      ?>
      <img src="<?php echo $row['image']; ?>" />
      <?php
      echo "<br><b>modelis: </b>". $row['modelis'] . " " ."<b>kategorija: </b>" .$row['kategorija'];
      echo "<br />";
      }
    
    mysql_close($con);
    
    ?>
     <a href="index.php">menu</a>

    and css.css

    div.fonas
    {
    width: 300px;
    height: 620px;
    display: block;
    background-color: #FFFF00;
    color: black;
    }
    input.atitraukimas
    {
    position: relative;
    right: 30px;
    float: right;
    }
    
    input.choose
    {
    position: relative;
    right: 30px;
    float: left;
    }
    
    select.atitraukimas
    {
    width: 155px;
    position: relative;
    right: 30px;
    float: right;
    }
    
    textarea.atitraukimas
    {
    display:block;
    width: 155px;
    height: 80px;
    position: relative;
    right: 30px;
    float: right;
    }
    font
    {
    text-align: center;
    font-weight:bold;
    display:block;
    }
    div.text
    {
    float:left;
    {

    my question is, how i can insert this to wordpress? 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • if you rename your index.php file to something like custom_page_template.php you can upload it to your current theme’s folder. Then just add a short bit of code at the top to identify this page as a page template.

    After that you can create a page in wordpress admin, and select this template from the page options screen.

    See more:
    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

    Also you would need to update the relative location of your stylesheet with
    href="<?php bloginfo('template_url'); ?>/style.css"

    as well as renaming style.css to something like custom_style.css because your theme will already have a style.css

    Thread Starter mariuse3

    (@mariuse3)

    Sorry, but if you can tell me more? about this ” Then just add a short bit of code at the top to identify this page as a page template.”

    what code, and where i need to add this?

    The code and an explaination was available in the link I had posted.

    This is the bit of code
    <?php
    /*
    Template Name: Custom Page Template
    */
    ?>

    Put it at the top of the main php file (which you have as index.php at the moment) then on the page editing screen you will have an option to select custom page template as the template for that page’s content.

    This method will include your custom page template, but it will be inside the wordpress theme’s main elements… your theme header will be written, then your custom page template and then the theme footer.

    I’m not explaining it as well as the codex can though, check that link for more info.

    Thread Starter mariuse3

    (@mariuse3)

    Thanks for information 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘how to integrate html/php page to wordpres’ is closed to new replies.