Ir ao conteúdo
  • Cadastre-se

Lerub

Membro Pleno
  • Posts

    170
  • Cadastrado em

  • Última visita

Tudo que Lerub postou

  1. HTML: <?php /** * The main template file. * * This is the most generic template file in a WordPress theme * and one of the two required files for a theme (the other being style.css). * It is used to display a page when nothing more specific matches a query. * E.g., it puts together the home page when no home.php file exists. * Learn more: http://codex.wordpress.org/Template_Hierarchy * * @bpackage Reddle * @since Reddle 1.0 */ get_header(); ?> <div id="primary"> <div id="content" role="main"> <?php if ( have_posts() ) : ?> <?php reddle_content_nav( 'nav-above' ); ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php /* Include the Post-Format-specific template for the content. * If you want to overload this in a child theme then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php reddle_content_nav( 'nav-below' ); ?> <?php else : ?> <article id="post-0" class="post no-results not-found"> <header class="entry-header"> <h1 class="entry-title"><?php _e( 'Nothing Found', 'reddle' ); ?></h1> </header><!-- .entry-header --> <div class="entry-content"> <p><?php _e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', 'reddle' ); ?></p> <?php get_search_form(); ?> </div><!-- .entry-content --> </article><!-- #post-0 --> <?php endif; ?> <div class="element1"><?php /** * A ... Category Template */ ?> <section id="primary" class="site-content"> <div id="content" role="main"> <?php // Check if there are any posts to display if ( have_posts() ) : ?> <?php // The Loop global $query_string; query_posts("{$query_string}cat=629&posts_per_page=3"); while ( have_posts() ) : the_post(); ?> <div class="hentry music"> <h1 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1> <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small> <?php the_post_thumbnail(); ?> <?php the_excerpt(); ?> <p class="postmetadata"><?php comments_popup_link( 'No comments yet', '1 comment', '% comments', 'comments-link', 'Comments closed'); ?></p> </div> <?php endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <?php endif; ?> </div> </section> </div> <div class="element2"><?php /** * A ... Category Template */ ?> <section id="primary" class="site-content"> <div id="content" role="main"> <?php // Check if there are any posts to display if ( have_posts() ) : ?> <?php // The Loop global $query_string; query_posts("{$query_string}cat=623&posts_per_page=3"); while ( have_posts() ) : the_post(); ?> <div class="hentry music"> <h1 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1> <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small> <?php the_post_thumbnail(); ?> <?php the_excerpt(); ?> <p class="postmetadata"><?php comments_popup_link( 'No comments yet', '1 comment', '% comments', 'comments-link', 'Comments closed'); ?></p> </div> <?php endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <?php endif; ?> </div> </section> </div> </div> </div> <!-- #content --> <!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?> CSS: .element1 .hentry { background:white; width:43%; font-size:124%; clear:left; } .element1.hentry h1 { font-size:143%; } .element1 .hentry h1 a { color:green; background:rgba(0,0,0,0); transition:ease 0.6s; } .element1 .hentry h1 a:hover { text-decoration:none; transition:ease 0.6s; opacity:.96; } .element2 .hentry { background:white; width:43%; font-size:124%; clear:right; display:flex; position:relative; left:47%; } .element2 .hentry h1 { font-size:143%; bottom:8%; } .element2 .hentry h1 a { color:#836fff; transition:ease 0.6s; } .element2 .hentry h1 a:hover { text-decoration:none; transition:ease 0.6s; opacity:.96; } Screenshot: https://screenshots.firefox.com/ClcoiQyPZG74MGCU/beta.suitedosnerds.com
  2. Será que eu ainda tenho chances de ressuscitar esse tópico? Estou tendo outro problema. Eu não consigo deixar o elemento 2 no topo da págilna. So embaixo e ao lado. Eu vou passar os códigos. HTML: https://pastebin.com/dh6M4j3E CSS: https://pastebin.com/reKP9b0X
  3. agora, em dispositivos móveis, sóbra abaixo, na página inicial. Eu já tentei corrigir com "@meida, más, não deu cérto. .dublagemhentry h1 figure { position:absolute; bottom:49%; z-index:-1; height:100%; } .dublagemhentry h1 figure img {width:100%; transition:ease 0.6s;} .dublagemhentry .hentry h1 a { color:#ff6363; } .dublagemhentry h1:hover figure img { transition:ease 0.6s; width:111%; }
  4. Eu fiz algomas correções na CSS. Eu esqueci de adicionar img em } .single, .entry-title figure [b]img[/b]{ width:100%; } para ajustar as dimensões da imagem. Em seguida, eu fiz isso: .single, .entry-title figure { position:absolute; bottom:181.4%; height:0; z-index:-1; } .single, .entry-title figure img{ width:100%; } No título, eu eu fiz isso: .single .entry-title { bottom:36%; position:fixed; font-family: Georgia, "Bitstream Charter", serif; font-size: 313%; z-index:-1; width:96%; } Eu deixei o cabeçalho e o conteúdo com o fundo da mesma cor que o body. .single #masthead { width:100%; background:gray; margin-bottom:44%; display:table; } #page #content { background:gray; margin-bottom:-4%; } E eu fiz isso em body: body { background: gray; position:absolute; top:5%; width:99%; } agora, só falta a pagina inicial. Edit: Eu estou tendo problemas com a página inicial. Seja em porcentágem, pixels e outras medias... no desktop, a imagem do titulo fica sobrando espaço "vazio" embaixo e no tablet sóbra acima.
  5. Eu estou tentando fazer isso há dois dias. E eu ando enfrentando problemas. Eu nem fiz as alterações para ficar "mobile friendly" - o post já é - por que ainda não terminei isso. Eu vou postar os trechos de códigos aqui, más, por via das duvidas, eu irei deixar um link do "Pastebin", com todo o CSS. E de preferência, eu sei que da para fazer isso sem AJAX. Então. para um website mais léve, só CSS. https://pastebin.com/x2ZuD0Q0 O código "padrão" do titulo dos post's é esse: .entry-title { font-family: Georgia, "Bitstream Charter", serif; font-size: 433%; position: absolute; bottom:6%; } O "content single" é esse: .single .entry-title { margin-bottom:36%; position:relative; font-family: Georgia, "Bitstream Charter", serif; font-size: 313%; z-index:1; Eu insiro a imgem junto ao titulo e uso o elemento HTML figure. <figure><img src="https://media.domain.com/thumbs/Thumb....png"></figure> Da cérto, más, eu estou tendo alguns problemas. Eu executo o test com dois posts em meu site para testes. Cada um com uma imagem na resolução de 1920x1080. Talvez pelo fato de eu ter tido que ajustar uma delas para télas retanguláres - é de 2007, se eu não me engano - esse bug acontéce. A distancia de cada imagem do post e do topo é diferente. Eu tentei deixar o título acima do post, já que, onde fica o post, fica uma parte sobrando, no topo. E eu tentei usar "position:fixed;", para dar aquele efeito na rolagem. Deu cérto, más, ao reposicionar os elementos, tudo que está acima desaparéce. Esse screenshot foi o máximo que eu consegui fazer. https://lh3.googleusercontent.com/sGoOJmaCSIac7ZVwDsbtQtcPf_3jBh1NSsWP6v44zWrTsxo0KB0mbkF7ltvVu97MRs-ARw[/img] Eu usei a ferramenta do "Mozilla Firefox" para tirar esse screenshot. Eu borrei o conteúdo para não correr o risco da moderação pensar que eu estou infringindo uma régra e divulgando o meu conteúdo. agora, eu irei mostrar os códigos do "header.php", "content-single.php" e "index.php". content-single.php https://pastebin.com/AEy3bKWQ header.php https://pastebin.com/K55i8n2X index.php https://pastebin.com/PPT8TzCm Eu já tentei tudo o que eu sei.
  6. Edit: Eu já resolvi o problema. Foi apenas um "erro de lógica". Eu pensei que, como o conector do piano eletrônico fosse transmitir o audio pra o Pc, eu teria que ligar o MIDIOUT. Eu liguei o outro plug e deu cérto. Eu executei esses passos: Eu não gravei um video com o instrumento,mas, é esse aqui: O dispositivo é esse: https://www.amazon.com/Yamaha-UX16-Midi-Interface/dp/B0002E2S1I/ref=sr_1_1?ie=UTF8&qid=1510778582&sr=8-1&keywords=yamaha+ux-16
  7. Sim. Tudo ok. Quando eu plugo o MIDi o visor digital não mostra nada. É normal?
  8. Eu recebi hoje o produto. ele é reconhecido pelo ALSA e pelo Jack. Porém, eu ligo o cabo Out na saída Out e nenhuma aplicação responde. As vezes, mesmo sem estar ligado na tomada, ao plugar o cabo MIDI, os leds acendem. Como eu resolvo isso? Eu já tentei 'apt-get install midi* (ou *midi, não lembro) e instalei 800M de pacóte. Alguns Yamaha support.
  9. Eu estou aprendendo a lidar com o PHPMail. Por enquanto, eu so aprendi a enviar para o e-mail que a pessoa digita no formulário. Eu vou ver como faço para incluir um log que registra todos os dados no formulário para ficar mais fácil de fazer a referencia para quem me enviou a imagem. E incluir um formulário para upload - tanto para o e-mail quanto um diretório do servidor - também. Edit: Eu temtei inserir esse código, para gerar o log com put $file = '/uploads/people.txt'; $current = file_get_contents($file); $current .= "$name"; file_put_contents($file, $current); e aparece esse erro E tentei de divérsas maneiras e deu o mesmo erro. <?php include("upload.php"); ?> <form action="<?= htmlspecialchars($_SERVER["PHP_SELF"]) ?>" method="post"> <h3>Envie a sua bizarrice!</h3> <fieldset> <input placeholder="Nome" type="text" name="name" value="<?= $name ?>"> <span><?= $name_error ?></span> </fieldset> <fieldset> <input placeholder="Email" type="text" name="email" value="<?= $email ?>"> <span><?= $email_error ?></span> </fieldset> <fieldset> <input placeholder="Site" type="text" name="url" value="<?= $url ?>"> <span><?= $url_error ?></span> </fieldset> <fieldset> <textarea value="<?= $message ?>" name="message"> </textarea> </fieldset> <fieldset> <button name="submit" type="submit" data-submit="Um instantinho...">Enviar</button> </fieldset> <div><?= $success ?></div> <?php //upload.php $name_error = $email_error = $url_error = ""; $name = $email = $message = $url = $success = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $name_error = "Name is required"; } else { $name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $name_error = "Apenas letras e espaços e branco"; } } if (empty($_POST["email"])) { $email_error = "Email is required"; } else { $email = test_input($_POST["email"]); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $email_error = "Invalid email format"; } } if (empty($_POST["url"])) { $url_error = ""; } else { $url = test_input($_POST["url"]); if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$url)) { $url_error = "Invalid URL"; } } if (empty($_POST["message"])) { $message = ""; } else { $message = test_input($_POST["message"]); } if ($name_error == '' and $email_error == '' and $phone_error == '' and $url_error == '' ){ $message_body = ''; unset($_POST['submit']); foreach ($_POST as $key => $value){ $message_body .= "$key: $value\n"; } $headers = 'From: ****' . "\r\n" . 'Reply-To: 8*****' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $to = $email; $subject = 'Recebemos...'; if (mail($to, $subject, $message)){ $success = "Enviado para o multiverso..."; $name = $email = $message = $url = ''; } } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data;
  10. Entendi sim, coléga. O que eu quis dizer é que o meu tempo anda apertado mesmo. Eu ainda dependo do AdSense para ganhar uma grana e o meu publico é bem especifico. O tipo que gosta de textão. É o que tem mais views no blog/.
  11. Obrogado pelo conselho. E eu estou fazendo isso. O problema é quela fase de aprendizado - CTRL-C CTRL-V - e eu preciso trabalhar en tempo integral, se quiser ganhar alguma grana com o blog. Eu só consegui que check se tem um arquivo selecionado. agora, enviar e-mail de confirmação imagens para um diretório. E seria bom saber quem enviou a imagem. <doctype html> <html> <head> <title>Tests</title><meta charset="utl8"> </head> <body> <?php if($_POST && isset($_FILES['my_file'])) { $from_email = '...'; //from mail, it is mandatory with some hosts $recipient_email = '...'; //recipient email (most cases it is your personal email) //Capture POST data from HTML form and Sanitize them, $sender_name = filter_var($_POST["sender_name"], FILTER_SANITIZE_STRING); //sender name $reply_to_email = filter_var($_POST["sender_email"], FILTER_SANITIZE_STRING); //sender email used in "reply-to" header $subject = filter_var($_POST["subject"], FILTER_SANITIZE_STRING); //get subject from HTML form $message = filter_var($_POST["message"], FILTER_SANITIZE_STRING); //message /* //don't forget to validate empty fields if(strlen($sender_name)<1){ die('Name is too short or empty!'); } */ //Get uploaded file data $file_tmp_name = $_FILES['my_file']['tmp_name']; $file_name = $_FILES['my_file']['name']; $file_size = $_FILES['my_file']['size']; $file_type = $_FILES['my_file']['type']; $file_error = $_FILES['my_file']['error']; if($file_error > 0) { die('Upload error or No files uploaded'); } //read from the uploaded file & base64_encode content for the mail $handle = fopen($file_tmp_name, "r"); $content = fread($handle, $file_size); fclose($handle); $encoded_content = chunk_split(base64_encode($content)); $boundary = md5("sanwebe"); //header $headers = "MIME-Version: 1.0\r\n"; $headers .= "From:".$from_email."\r\n"; $headers .= "Reply-To: ".$reply_to_email."" . "\r\n"; $headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n"; //plain text $body = "--$boundary\r\n"; $body .= "Content-Type: text/plain; charset=ISO-8859-1\r\n"; $body .= "Content-Transfer-Encoding: base64\r\n\r\n"; $body .= chunk_split(base64_encode($message)); //attachment $body .= "--$boundary\r\n"; $body .="Content-Type: $file_type; name=".$file_name."\r\n"; $body .="Content-Disposition: attachment; filename=".$file_name."\r\n"; $body .="Content-Transfer-Encoding: base64\r\n"; $body .="X-Attachment-Id: ".rand(1000,99999)."\r\n\r\n"; $body .= $encoded_content; $sentMail = @mail($recipient_email, $subject, $body, $headers); if($sentMail) //output success or failure messages { die('Thank you for your email'); }else{ die('Could not send mail! Please check your PHP mail configuration.'); } } ?> <form enctype="multipart/form-data" method="POST" action=""> <label>Your Name <input type="text" name="sender_name" /> </label> <label>Your Email <input type="email" name="sender_email" /> </label> <label>Subject <input type="text" name="subject" /> </label> <label>Message <textarea name="message"></textarea> </label> <label>Attachment <input type="file" name="my_file" /></label> <label><input type="submit" name="button" value="Submit" /></label> </form> </body> </html>
  12. Isso eu já estou tentando resolver. Mas, eu ainda preciso das informações de quem enviou. Assim eu posso fazer uma referenccia a(o) visitante que enviou a imagem. Jajá eu volto com o código. Edit: Eentão... tem esse código, que eu postei aqui antes. <doctype html> <html> <head> <title>Tests</title><meta charset="utl8"> </head> <body> <?php if(isset($_POST['submit'])) { //The form has been submitted, prep a nice thank you message $output = '<h1>Thanks for your file and message!</h1>'; //Set the form flag to no display (cheap way!) $flags = 'style="display:none;"'; //Deal with the email $to = '[email protected]'; $subject = 'a file for you'; $message = strip_tags($_POST['message']); $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name']))); $filename = $_FILES['file']['name']; $boundary =md5(date('r', time())); $headers = "From: [email protected]\r\nReply-To: [email protected]"; $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\""; $message="This is a multi-part message in MIME format. --_1_$boundary Content-Type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $message --_2_$boundary-- --_1_$boundary Content-Type: application/octet-stream; name=\"$filename\" Content-Transfer-Encoding: base64 Content-Disposition: attachment $attachment --_1_$boundary--"; mail($to, $subject, $message, $headers); } ?> <?php echo $output; ?> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" <?php echo $flags;?>> <p><label for="message">Message</label> <textarea name="message" id="message" cols="20" rows="8"></textarea></p> <p><label for="file">File</label> <input type="file" name="file" id="file"></p> <p><input type="submit" name="submit" id="submit" value="send"></p> </form> </body> </html> Só que, mesmo sem completar nenhum campo, aparece a mensagem de agradecimento e retorna um erro. E esse é o unico código que eu testei, que não redireciona para outra página. Resultado:
  13. Eu usei o termo errado. Eu quis dizer: CHECAR. É para que quem visita o meu blog possa enviar imagens referente a uma seção que eu penso em inaugurar. E seria legal se a pessoa pudesse deixar o seu nome e/ou nick. O e-mail é para avisar que a imagem foi publicada.
  14. Como eu faço para validar o Upload também? E enviar os dados para um arquivo de texto? Eu consegui um meio de não ter que atualizar a página. Verei como implementar a validação do formuláril e-mail. <?php if(isset($_POST['submit'])) { //The form has been submitted, prep a nice thank you message $output = '<h1>Thanks for your file and message!</h1>'; //Set the form flag to no display (cheap way!) $flags = 'style="display:none;"'; //Deal with the email $to = '[email protected]'; $subject = 'a file for you'; $message = strip_tags($_POST['message']); $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name']))); $filename = $_FILES['file']['name']; $boundary =md5(date('r', time())); $headers = "From: [email protected]\r\nReply-To: [email protected]"; $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\""; $message="This is a multi-part message in MIME format. --_1_$boundary Content-Type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $message --_2_$boundary-- --_1_$boundary Content-Type: application/octet-stream; name=\"$filename\" Content-Transfer-Encoding: base64 Content-Disposition: attachment $attachment --_1_$boundary--"; mail($to, $subject, $message, $headers); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>MailFile</title> </head> <body> <?php echo $output; ?> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" <?php echo $flags;?>> <p><label for="message">Message</label> <textarea name="message" id="message" cols="20" rows="8"></textarea></p> <p><label for="file">File</label> <input type="file" name="file" id="file"></p> <p><input type="submit" name="submit" id="submit" value="send"></p> </form> </body> </html>
  15. eu desisto! Preciso terminar um post mega atrasado. Alguma ideia para checar todos os campos?
  16. Como eu impéço o redirecionamento para "uploads.php" e consigo fazer os dois codigos PHP funcionarem juntos? Eu estou tendo problemas com isso.
  17. Eu resolvi voltar a usar esse código: <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { echo "Sorry, file already exists."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 10000000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "apng" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG, APNG and GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } } // define variables and set to empty values $nameErr = $emailErr = $genderErr = $websiteErr = ""; $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address is well-formed if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } } if (empty($_POST["website"])) { $website = ""; } else { $website = test_input($_POST["website"]); // check if URL address syntax is valid (this regular expression also allows dashes in the URL) if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) { $websiteErr = "Invalid URL"; } } if (empty($_POST["comment"])) { $comment = ""; } else { $comment = test_input($_POST["comment"]); } if (empty($_POST["gender"])) { $genderErr = "Gender is required"; } else { $gender = test_input($_POST["gender"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> O unico problema é o fato da página ser redirecionada sem a confirmação dos dados.
  18. Até o momento, eu cheguei nesse resultado. Form: <p><span class="error">* required field.</span></p> <form action="upload.php <?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" enctype="multipart/form-data"> Select image to upload: <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload Image" name="submit"> Name: <input type="text" name="name" value="<?php echo $name;?>"> <span class="error">* <?php echo $nameErr;?></span> <br><br> E-mail: <input type="text" name="email" value="<?php echo $email;?>"> <span class="error">* <?php echo $emailErr;?></span> <br><br> Website: <input type="text" name="website" value="<?php echo $website;?>"> <span class="error"><?php echo $websiteErr;?></span> <br><br> Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea> <br><br> Gender: <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male">Male <span class="error">* <?php echo $genderErr;?></span> <br><br> </form> PHP: <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { echo "Sorry, file already exists."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 10000000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "apng" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG, APNG and GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } } // define variables and set to empty values $nameErr = $emailErr = $genderErr = $websiteErr = ""; $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address is well-formed if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } } if (empty($_POST["website"])) { $website = ""; } else { $website = test_input($_POST["website"]); // check if URL address syntax is valid (this regular expression also allows dashes in the URL) if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) { $websiteErr = "Invalid URL"; } } if (empty($_POST["comment"])) { $comment = ""; } else { $comment = test_input($_POST["comment"]); } if (empty($_POST["gender"])) { $genderErr = "Gender is required"; } else { $gender = test_input($_POST["gender"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> Só que agora, o upload não é concluido e é gerado uma mensagem de erro 404 . Edit Eu consegui uma maneira de comtornar o erro. Eu apago <?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?> que é a medida de segurança, para que não possam injetar código pela URL. E ainda da para efetuar o upload sem preencher os campos obrigatórios. Esse tutorial ensinou uma coisa interessante - e que eu aprendi com o WP - mas, ainda não consigo mesclar isso com outro tipo de formulario. Edit2 Segui esse tutorial e gera a seguinte mensagem: PHP: <?php echo '<pre>'; var_export($_POST); echo '</pre>'; echo '<pre>'; var_export($_FILES); echo '</pre>'; $error = ''; if ($_FILES['filePhoto']['error'] > 0) { $error = 'Sorry, there was an error in uploading the file'; } elseif ($_FILES['filePhoto']['type'] != 'image/gif', 'image/png', 'image/jpeg') { $error = 'Only .gif files are allowed'; } elseif ($_FILES['filePhoto']['size'] > 11000000) { $error = 'Files size should be less than 50KB'; } else { $sizeInfo = getimagesize($_FILES['filePhoto']['tmp_name']); if ($sizeInfo[0] > 100 || $sizeInfo[1] > 125) { $error = 'Desculpe! Você ultrapasspu o limite de 11M'; } else { move_uploaded_file($_FILES['filePhoto']['tmp_name'], "uploads/".$_POST['txtUsername'].".gif"); } } if ($error == '') { echo 'Thnkk yooouuu!'; } else { echo $error; } ?> Sugestões?
  19. Ok. Eu vou dar uma olhada nisso. Eu parei com PHP, por um tempo, até migrar para WordPress. Eu vou estudar mais sobre isso.
  20. Só verificar se é um e-mail válido. Apesar que eu não pretendo enviar uma notificação, por enquanto. É só um registro de quem enviou a imagem. agora que eu cochilei um pouco, eu vou ver como resolver isso. Eu adimito ter copiado isso da W3C. Hehe! E eu nunca consegui fazer Ajax funcuinar. já consegui até um "Hello" em PythonWeb...
  21. Olá. Eu sou meio "iniciante" - eu já "brinquei" com PHP há anos atrás - em PHP. e pretendo criar um formulario para upload, com verificação de e-mail. E seria bom se as mensagens de aviso aparecessem na mesma página. Se isso não for possível, eu corrijo com o codigo do Wordpress. E eu já aviso que sou um pouco "orgulhoso" - se essa é a expressão corréta - então, APENAS ME DIGAM AS ALTERAÇÕES QUE EU DEVO FAZER! Formulario: <form action="upload.php" method="post" enctype="multipart/form-data"> Select image to upload: <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload Image" name="submit"> </form> PHP: <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { echo "Sorry, file already exists."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 10000000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "apng" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG, APNG and GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } } ?>
  22. Desculpe. Eu fiquei devendo explicações. Tive um probleminha com o cache. Tive até que reiniciar o modem - que não tem nenhuma relação com o conteudo hospedado. Tópico "solved".
  23. Então, galéra. Sou novo nessa área de registro de dominios. Registrei o meu, os CNAMES do blogspot foram adicionado e hoje, quando os deletei, para usar o WordPress, sem o "WWW", cai na pagina de erro do Google e com, o navegador reconhece como inexistente. Os subdominios funcionam bem. Como eu resolvo isso: O SUPORTE TA OFF-LINE!

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Ebook grátis: Aprenda a ler resistores e capacitores!

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!